Q:

Write a Scala program to check whether two given integer values are in the range 20..50 inclusive. Return true if 1 or other is in the said range otherwise false

0

Write a Scala program to check whether two given integer values are in the range 20..50 inclusive. Return true if 1 or other is in the said range otherwise false.

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 <= 20 || y >= 50) || (y <= 20 || x >= 50);
    }     
   def main(args: Array[String]): Unit = {
      println("Result: " + test(20, 84));
      println("Result: " + test(14, 50));
      println("Result: " + test(11, 45));
      println("Result: " + test(25, 40));
    }
}

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