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