Write a Scala program to check whether a given positive number is a multiple of 3 or a multiple of 7.
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
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