Write a Scala program to check two given integers, and return true if one of them is 30 or if their sum is 30.
object scala_basic { def test(x:Int, y:Int) : Boolean = { x == 30 || y == 30 || x + y == 30 } def main(args: Array[String]): Unit = { println("Result: " + test(30, 0)); println("Result: " + test(25, 5)); println("Result: " + test(30, 20)); println("Result: " + test(25, 20)); } }
Sample Output:
Result: true 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.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer