-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcase_switch.java
More file actions
29 lines (29 loc) · 789 Bytes
/
case_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
import java.util.Scanner;
public class case_switch extends qwertyuiop
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter 2 numbers: ");
int a=sc.nextInt();
int b=sc.nextInt();
System.out.println("Enter 1 for addition and 2 for subtraction");
System.out.println("Enter 3 for multiplication and 4 for division");
int c=sc.nextInt();
int d=0;
switch(c)
{
case 1:
d=add(a,b);
break;
case 2:
d=subtract(a,b);
case 3:
d=multiply(a,b);
break;
case 4:
d=divide(a,b);
}
System.out.println(d);
}
}