Write a Scala program to check two given integers whether either of them is in the range 100..200 inclusive

  • برمجة سكالا

Write a Scala program to check two given integers whether either of them is in the range 100..200 inclusive.

 

الأجوبة

object scala_basic {
  def test(x: Int, y: Int): Boolean = 
    {
      (x >= 100 && x <= 200) || (y >= 100 && y <= 200);
    }
     
   def main(args: Array[String]): Unit = {
      println("Result: " + test(100, 199));
      println("Result: " + test(250, 300));
      println("Result: " + test(105, 190));
    }
}

Sample Output:

Result: true
Result: false
Result: true
هل كان المحتوى مفيد؟

معلومات ذات صلة

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...