Write a Scala program to check whether one of the given temperatures is less than 0 and the other is greater than 100
- برمجة سكالا
- 2021-09-23
- mhanasmh00489829403
الأجوبة
Scala Code:
object scala_basic {
def test(temp1: Int, temp2: Int): Boolean =
{
(temp1 < 0 && temp2 > 100) || (temp2 < 0 && temp1 > 100)
}
def main(args: Array[String]): Unit = {
println("Result: " + test(120, -1));
println("Result: " + test(-1, 120));
println("Result: " + test(2, 120));
}
}
Sample Output:
Result: true Result: true Result: false
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة