Write a Scala program to convert the last 4 characters of a given string in upper case. If the length of the string has less than 4 then uppercase all the characters
- برمجة سكالا
- 2021-09-23
- mhanasmh00489829403
الأجوبة
object scala_basic {
def test(str1: String): String = {
str1.take(str1.length() - 4) + str1.drop(str1.length() - 4).toUpperCase()
}
def main(args: Array[String]): Unit = {
println("Result: " + test("Scala"));
println("Result: " + test("Python"));
println("Result: " + test("abc"));
}
}
Sample Output:
Result: SCALA Result: PyTHON Result: ABC
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة