-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenudrivecalculatorusingswitchcase.java
More file actions
47 lines (46 loc) · 1.46 KB
/
Copy pathmenudrivecalculatorusingswitchcase.java
File metadata and controls
47 lines (46 loc) · 1.46 KB
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
37
38
39
40
41
42
43
44
45
46
47
import java.util.*;
public class menudrivecalculatorusingswitchcase
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.println("enter your choice between (1-4):");
System.out.println("1.Addition");
System.out.println("2.Substraction");
System.out.println("3.Multipication");
System.out.println("4.Division");
int ch=s.nextInt();
switch(ch)
{
case 1:
System.out.println("Enter two number:");
int a=s.nextInt();
int b=s.nextInt();
float c=a+b;
System.out.println("The Sum is: "+c);
break;
case 2:
System.out.println("Enter two number:");
a=s.nextInt();
b=s.nextInt();
c=a-b;
System.out.println("The substraction is: "+c);
break;
case 3:
System.out.println("Enter two number:");
a=s.nextInt();
b=s.nextInt();
c=a*b;
System.out.println("The Multiplication is: "+c);
break;
case 4:
System.out.println("Enter two number:");
a=s.nextInt();
b=s.nextInt();
c=a/b;
System.out.println("The division is: "+c);
break;
default:System.out.println("Invalid choice");
}
}
}