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.
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
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer