Write a Scala program to check whether one of the given temperatures is less than 0 and the other is greater than 100.
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
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Scala Code:
Sample Output: