Write a Scala program to check whether two given integers are in the range 40..50 inclusive, or they are both in the range 50..60 inclusive
- برمجة سكالا
- 2021-09-23
- mhanasmh00489829403
الأجوبة
object scala_basic {
def test(x: Int, y: Int): Boolean = {
List(x, y).forall { m => m >= 40 && m <= 50 } || List(x, y).forall { n => n >= 50 && n <= 60 }
}
def main(args: Array[String]): Unit = {
println("Result: " + test(78,95));
println("Result: " + test(25,35));
println("Result: " + test(40,50));
println("Result: " + test(55,60));
}
}
Sample Output:
Result: false Result: false Result: true Result: true
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة