-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuBase.java
More file actions
44 lines (38 loc) · 1.23 KB
/
MenuBase.java
File metadata and controls
44 lines (38 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
package Assignment;
import java.util.Scanner;
public class MenuBase {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int choice;
int num;
double result = 0;
while(true)
{
System.out.println("Enter your Choice\n1:Addition\n2:Subtraction\n3:Multiplication\n4:Division\n5:Exit");
choice = sc.nextInt();
switch(choice)
{
case 1: System.out.println("Enter number to Add");
num = sc.nextInt();
result = result + num;
break;
case 2: System.out.println("Enter number to Sub");
num = sc.nextInt();
result = result - num;
break;
case 3: System.out.println("Enter number to mul");
num = sc.nextInt();
result = result * num;
break;
case 4: System.out.println("Enter number to div");
num = sc.nextInt();
result = result / num;
break;
case 5: System.exit(0);
default: System.out.println("Wrong Choice");
}
System.out.println(result);
}
}
}