Q:

Write a Scala program to check whether a given positive number is a multiple of 3 or a multiple of 7

0

Write a Scala program to check whether a given positive number is a multiple of 3 or a multiple of 7.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

object scala_basic {
  def test(n: Int): Boolean = 
    {
    n % 3 == 0 || n % 7 == 0;
    }
     
   def main(args: Array[String]): Unit = {
      println("Result: " + test(3));
      println("Result: " + test(14));
      println("Result: " + test(12));
      println("Result: " + test(37));
    }
}

Sample Output:

Result: true
Result: true
Result: true
Result: false

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