-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.java
More file actions
38 lines (38 loc) · 999 Bytes
/
Calculator.java
File metadata and controls
38 lines (38 loc) · 999 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
30
31
32
33
34
35
36
37
38
import java.util.Scanner;
public class Calculator
{
public static void main(String[] args)
{
// int cs=0;
Scanner scan = new Scanner(System.in);
System.out.println(" Enter first number:");
int num1 = scan.nextInt();
System.out.println(" Enter Second number:");
int num2 = scan.nextInt();
System.out.println(" Enter\n 1 : ADD || 2 :SUBTRACT\n3 : MULTIPLY || 4: DIVIDE");
int cs = scan.nextInt();
System.out.println(" :" +cs);
switch(cs)
{
case 1:
int Sum = num1+num2;
System.out.println("Sum of two number is "+Sum);
break;
case 2:
int Sub = num1-num2;
System.out.println("SUBTRACT :"+Sub);
break;
case 3:
int Mul = num1*num2;
System.out.println("MULTIPLY:"+Mul);
break;
case 4:
float Div = num1/num2;
System.out.println("DIVIDE:"+Div);
break;
default:
System.out.println("Enter a valid number");
break;
}
}
}