-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwitch_main.java
More file actions
89 lines (82 loc) · 2.56 KB
/
Copy pathSwitch_main.java
File metadata and controls
89 lines (82 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import java.util.Scanner;
public class Switch_main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// System.out.print("Enter fruit name: ");
// String fruit= in.next();
// if ( fruit.equals("mango")){
// System.out.println("king of fruit ");
// }
//
// if (fruit.equals("apple")){
// System.out.println("A sweet red fruit");
// }
//Switch case:
//if breaks is not provided then it will execute all cases
// switch (fruit) {
// case "mango":
// System.out.println("King of fruit");
// break;
// case "Apple":
// System.out.println("A sweet red fruit");
// break;
// case "Orange":
// System.out.println("Round fruit");
// break;
// case "Grapes":
// System.out.println("Small fruit");
// break;
// default:
// System.out.println("Please enter a valid fruit ");
// break;
// }
int day = in.nextInt();
switch (day) {
case 1:
int a = 5;
int b = 6;
int c = a + b;
System.out.println(c);
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
case 4:
System.out.println("Thursday");
break;
case 5:
System.out.println("Friday");
break;
case 6:
System.out.println("Saturday");
break;
case 7:
System.out.println("Sunday");
break;
}
switch (day) {
case 1:
case 2:
case 3:
case 4:
System.out.println("Here is break");
break;
case 5:
case 6:
case 7:
System.out.println("This is second break");
break;
case 8:
}
// switch (day) {
// case 1, 2, 3, 4 -> System.out.println("Here is break");
// case 5, 6, 7 -> System.out.println("This is second break");
// case 8 -> {
// }
// }
}
}