Q:

Write a Scala program to check two given integers, and return true if one of them is 30 or if their sum is 30

0

Write a Scala program to check two given integers, and return true if one of them is 30 or if their sum is 30.

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now