Q:

Write a Scala program to check the largest number among three given integers

0

Write a Scala program to check the largest number among three given integers.

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, z: Int): Int = {
       List(x, y, z).max
    }
     
   def main(args: Array[String]): Unit = {
      println("Result: " + test(1,2,3));
      println("Result: " + test(1,3,2));
      println("Result: " + test(1,1,1));
      println("Result: " + test(1,2,2));
    }
  }

Sample Output:

Result: 3
Result: 3
Result: 1
Result: 2

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