-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram33.java
More file actions
52 lines (39 loc) · 1.41 KB
/
Copy pathprogram33.java
File metadata and controls
52 lines (39 loc) · 1.41 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
52
// Menu - Driven Java Program --
import java.util.Scanner;
public class program33 {
public static void main(String[] args) {
System.out.println("---- Simple Calculator ----");
Scanner sc = new Scanner(System.in);
System.out.print("Enter Num1 : ");
int num1 = sc.nextInt();
System.out.println("Enter Num2 : ");
int num2 = sc.nextInt();
System.out.print("Enter your Choice : ");
System.out.println("1 . Addition ");
System.out.println("2 . Subtraction ");
System.out.println("3 . Multiplication ");
System.out.println("4 . Division ");
System.out.println("5 . Exit ");
int choice = sc.nextInt();
switch(choice){
case 1:
System.out.println("Addition = " + (num1+num2));
break;
case 2:
System.out.println("Subtraction = " + (num1-num2));
break;
case 3:
System.out.println("Multiplication = " + (num1*num2));
break;
case 4:
System.out.println("Division = " + (num1/num2));
break;
case 5:
System.out.println("Exiting the program !!!!");
break;
default:
System.out.println("Invalid Choice !!!!");
}
sc.close();
}
}