forked from iRupam/NewtonSchoolInfinityJune21
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwitchExample1.java
More file actions
36 lines (34 loc) · 974 Bytes
/
SwitchExample1.java
File metadata and controls
36 lines (34 loc) · 974 Bytes
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
package InfinityJune21.DoubtSessionJun26;
public class SwitchExample1 {
public static void main(String[] args) {
/*
1 - add
2 - subtract
3 - multiply
4 - divide
*/
int choice = 1;
int num1 = 10, num2 = 20, result = 0;
switch(choice) {
case 1:
result = num1 + num2;
System.out.println("Case 1");
break;
case 2:
result = num1 - num2;
System.out.println("Case 2");
break;
case 3:
result = num1 * num2;
System.out.println("Case 3");
break;
case 4:
result = num1 / num2;
System.out.println("Case 4");
break;
default:
result = 0;
}
System.out.println("Result: " + result);
}
}