forked from harshitbansal373/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator.java
41 lines (41 loc) · 828 Bytes
/
Calculator.java
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
import java.util.Scanner;
class Calculator
{
public static void main(String args[]){
int a,b,value;
System.out.println("enter two numbers");
Scanner number = new Scanner(System.in);
a = number.nextInt();
b = number.nextInt();
System.out.println("press 1 for addition\n press 2 for subtraction\n press 3 for division\n press 4 for multiplication");
value = number.nextInt();
switch(value)
{
case 1 :
{
System.out.println("addition is = "+(a+b));
break;
}
case 2 :
{
System.out.println("subtraction is = "+(a-b));
break;
}
case 3 :
{
System.out.println("division is = "+(a/b));
break;
}
case 4 :
{
System.out.println("multiplication is = "+(a*b));
break;
}
default :
{
System.out.println("you insert wrong keyword");
break;
}
}
}
}