-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.java
More file actions
46 lines (44 loc) · 1.38 KB
/
Calculator.java
File metadata and controls
46 lines (44 loc) · 1.38 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
import java.util.*;
class Calculator{
public static void main(String args[]){
int a,b,input;
Scanner sc= new Scanner(System.in);
System.out.print("Enter the first number: ");
a=sc.nextInt();
System.out.print("Enter the second number: ");
b=sc.nextInt();
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");
System.out.println("Press 5 for Modulo\n");
System.out.print("Enter your choice: ");
input=sc.nextInt();
sc.close();
switch (input) {
case 1:{
System.out.println("The sum is "+(a+b));
break;
}
case 2:{
System.out.println("The diff is "+(a-b));
break;
}
case 3:{
System.out.println("The div is "+(a/b));
break;
}
case 4:{
System.out.println("The product is "+(a*b));
break;
}
case 5:{
System.out.println("The modulo is "+(a%b));
break;
}
default:
System.out.println("Enter form range 1-5");
break;
}
}
}