-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.java
More file actions
51 lines (39 loc) · 1.23 KB
/
Copy pathcalculator.java
File metadata and controls
51 lines (39 loc) · 1.23 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
48
49
50
51
import java.util.Scanner;
class calculate
{
public static void main(int a, int b)
{
int choice;
double result;
Scanner sc = new Scanner(System.in);
System.out.println("Enter Your Choice : ");
System.out.println("1. Addition : ");
System.out.println("2. Substraction : ");
System.out.println("3. Multiplication : ");
System.out.println("4. Division : ");
choice = sc.nextInt();
System.out.println("Enter The First Number : ");
int num1 = sc.nextInt();
System.out.println("Enter The Second Number : ");
int num2 = sc.nextInt();
switch (choice) {
case 1:
result = num1 + num2;
System.out.println("Result = " +result);
break;
case 2:
result = num1 - num2;
System.out.println("Result = " +result);
break;
case 3:
result = num1 * num2;
System.out.println("Result = " +result);
break;
case 4:
result = num1 % num2;
System.out.println("Result = " +result);
default:
break;
}
}
}