004-003-007
Switch Statement: Weekday Determination
Easy
Problem Description
switch statement: Weekday Determination
Learning Objective: Perform multi-value branching with switch statement
In this problem, you will create a program that reads an integer (1-7) from standard input, uses a switch statement with cases 1 through 7 to determine the corresponding weekday name, and displays the result in the format "[Weekday]" to standard output.
Determine weekday from number (1-7). Display weekday name using switch statement.
Input
Line 1: Weekday number (integer 1-7)
Output
[Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday]
1=Monday, 2=Tuesday, ..., 7=Sunday.
Test Cases
※ Output examples follow programming industry standards
Input:
1
Expected Output:
Monday
Input:
5
Expected Output:
Friday
Input:
7
Expected Output:
Sunday
Input:
-10
Expected Output:
Unknown
Input:
999
Expected Output:
Unknown
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 9 free executions remaining
