You want to write a Kotlin when expression that prints "Weekend" if the day is either "Saturday" or "Sunday", "Weekday" if the day is any other day of the week, and "Invalid" for any other input. Which code correctly implements this?
Step 1: Check correct multiple condition syntax for weekend days
when(day) {
"Saturday", "Sunday" -> println("Weekend")
"Monday", "Tuesday", "Wednesday", "Thursday", "Friday" -> println("Weekday")
else -> println("Invalid")
} correctly uses commas to separate "Saturday" and "Sunday" to match either day.
Step 2: Verify handling of other days and else case
when(day) {
"Saturday", "Sunday" -> println("Weekend")
"Monday", "Tuesday", "Wednesday", "Thursday", "Friday" -> println("Weekday")
else -> println("Invalid")
} lists all weekdays explicitly and uses else for invalid inputs, matching the problem requirements.