Kotlinlearncs.online LogoJava
Return to List

Solve: Primes Switch Statement

Created By: Ellen Spertus
/ Version: 2024.1.0

Write a function printStatus() that takes an int argument. If the value is 0 or 1, it should print "neither prime nor composite". If the value is 2, 3, 5, or 7, it should print "prime". If the value is 4, 6, 8, or 9, it should print "composite". If it is any other value, it should print "out of range". Use a switch statement.

Related Lessons

Stuck? You may find these lessons helpful: