Kotlinlearncs.online LogoJava
Return to List

Homework: Primes Switch Expression

Created By: Ellen Spertus
/ Version: 2024.1.0

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

Related Lessons

Stuck? You may find these lessons helpful: