- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcase_switch.java
More file actions
Latest commit
29 lines (29 loc) · 789 Bytes
/
Copy pathcase_switch.java
File metadata and controls
29 lines (29 loc) · 789 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
importjava.util.Scanner;
publicclasscase_switchextendsqwertyuiop
{
publicstaticvoidmain(Stringargs[])
{
Scannersc=newScanner(System.in);
System.out.println("Enter 2 numbers: ");
inta=sc.nextInt();
intb=sc.nextInt();
System.out.println("Enter 1 for addition and 2 for subtraction");
System.out.println("Enter 3 for multiplication and 4 for division");
intc=sc.nextInt();
intd=0;
switch(c)
{
case1:
d=add(a,b);
break;
case2:
d=subtract(a,b);
case3:
d=multiply(a,b);
break;
case4:
d=divide(a,b);
}
System.out.println(d);
}
}