Kotlin when

// Step 1: Declare a function named "checkNumber"
fun checkNumber(number: Int) {
    // Step 2: Use a when expression to check the value of the number
    when (number) {
        0 -> println("Number is zero") // Step 3: Print a message if the number is 0
        in 1..9 -> println("Number is between 1 and 9") // Step 4: Print a message if the number is between 1 and 9 (inclusive)
        10, 20 -> println("Number is either 10 or 20") // Step 5: Print a message if the number is either 10 or 20
        else -> println("Number is none of the above") // Step 6: Print a default message if the number doesn't match any of the above cases
    }
}

// Step 7: Call the function with different values to test the when expression
fun main() {
    checkNumber(5) // Testing with a number between 1 and 9
    checkNumber(0) // Testing with 0
    checkNumber(20) // Testing with 20
    checkNumber(15) // Testing with a number that doesn't match any specific case
}