-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSwitchCase.java
More file actions
32 lines (27 loc) · 960 Bytes
/
SwitchCase.java
File metadata and controls
32 lines (27 loc) · 960 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
import java.util.Scanner;
public class SwitchCase {
public static void main(String[] args) {
System.out.println("Enter your choice : ");
System.out.println("Press 1 for addition");
System.out.println("Press 2 for subtraction");
System.out.println("Press 3 for division");
System.out.println("Press 4 for multiplication");
Scanner scanner = new Scanner(System.in);
int choice = scanner.nextInt();
System.out.println("Enter first num : ");
int fnum = scanner.nextInt();
System.out.println("Enter second num : ");
int snum = scanner.nextInt();
int result = 0;
switch (choice) {
case 1:
result = fnum + snum;
break;
case 2:
result = fnum - snum;
break;
default:
break;
}
}
}