Write a Scala program to compute the sum of the two given integer values. If the two values are the same, then return triples their sum
- برمجة سكالا
- 2021-09-23
- mhanasmh00489829403
الأجوبة
object scala_basic {
def test(x:Int, y:Int) : Int =
{
if (x == y) (x + y) * 3 else x + y
}
def main(args: Array[String]): Unit = {
println("Result: " + test(1, 2));
println("Result: " + test(2, 2));
}
}
Sample Output:
Result: 3 Result: 12
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة