Write a Scala program to check two given integers, and return true if one of them is 30 or if their sum is 30
- برمجة سكالا
- 2021-09-23
- mhanasmh00489829403
الأجوبة
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
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة