Challenge: Weekday Switch
Taak
Swipe to start coding
Write a program that takes an integer from 1
to 7
and prints the corresponding day of the week.
- Use a
switch
statement to compare the value ofday
to numbers 1-7. - For each case (1 to 7), print the corresponding day of the week.
- Add
break
after each case to prevent fall-through. - Add a
default
case to handle invalid inputs (numbers outside 1-7). In this case, print"Invalid day"
.
Note
Please note that in our system, the counting of days in the week starts on Monday. So, the first day is Monday, the second is Tuesday, and so on.
Oplossing
solution.java
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 2. Hoofdstuk 8
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Awesome!
Completion rate improved to 2.7
Challenge: Weekday Switch
Veeg om het menu te tonen
Taak
Swipe to start coding
Write a program that takes an integer from 1
to 7
and prints the corresponding day of the week.
- Use a
switch
statement to compare the value ofday
to numbers 1-7. - For each case (1 to 7), print the corresponding day of the week.
- Add
break
after each case to prevent fall-through. - Add a
default
case to handle invalid inputs (numbers outside 1-7). In this case, print"Invalid day"
.
Note
Please note that in our system, the counting of days in the week starts on Monday. So, the first day is Monday, the second is Tuesday, and so on.
Oplossing
solution.java
Was alles duidelijk?
Bedankt voor je feedback!
Awesome!
Completion rate improved to 2.7Sectie 2. Hoofdstuk 8
single