1int day = 4;
2switch (day) {
3 case 6:
4 System.out.println("Today is Saturday");
5 break;
6 case 7:
7 System.out.println("Today is Sunday");
8 break;
9 default:
10 System.out.println("Looking forward to the Weekend");
11}
12// Outputs "Looking forward to the Weekend"
1//import java.util.Scanner;
2System.out.println("What day is today ? ");
3 System.out.println("First Letter Capital");
4 String a =scanner.nextLine();
5
6 switch(a) {
7 case "Sunday": System.out.println("Its Sunday");
8 break;
9 case "Monday": System.out.println("Its Monday");
10 break;
11 case "Tuesday": System.out.println("Its tuesday");
12 break;
13 case "Wednesday": System.out.println("Its Wednesday");
14 break;
15 case "Thursday": System.out.println("Its Thursday");
16 break;
17 case "Friday": System.out.println("Its Friday");
18 break;
19 case "Saturday":System.out.println("Its holiday ");
20 break;
1
2int day = 4;
3switch (w3exercise_input_no_0) {
4 w3exercise_input_no_1 1:
5 System.out.println("Saturday");
6 break;
7 w3exercise_input_no_2 2:
8 System.out.println("Sunday");
9 w3exercise_input_no_3;
10 w3exercise_input_no_4:
11 System.out.println("Weekend");
12}
13
1int day = 4;
2switch (day) {
3 case 6:
4 System.out.println("Today is Saturday");
5 break;
6 case 7:
7 System.out.println("Today is Sunday");
8 break;
9 default:
10 System.out.println("Looking forward to the Weekend");
11}
12// Outputs "Looking forward to the Weekend"
13