Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Challenge: Weekday Switch | Basic Types and Operations
Java Basics (unit tests)
course content

Contenuti del Corso

Java Basics (unit tests)

Java Basics (unit tests)

1. Getting Started
2. Basic Types and Operations
3. Loops
4. Arrays
5. String

book
Challenge: Weekday Switch

Compito

Swipe to start coding

Write a program that takes an integer from 1 to 7 and prints the corresponding day of the week.

  1. Use a switch statement to compare the value of day to numbers 1-7.
  2. For each case (1 to 7), print the corresponding day of the week.
  3. Add break after each case to prevent fall-through.
  4. 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.

Soluzione

java

solution

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 8
toggle bottom row

book
Challenge: Weekday Switch

Compito

Swipe to start coding

Write a program that takes an integer from 1 to 7 and prints the corresponding day of the week.

  1. Use a switch statement to compare the value of day to numbers 1-7.
  2. For each case (1 to 7), print the corresponding day of the week.
  3. Add break after each case to prevent fall-through.
  4. 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.

Soluzione

java

solution

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 2. Capitolo 8
Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Siamo spiacenti che qualcosa sia andato storto. Cosa è successo?
some-alt