-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuDriven.java
37 lines (36 loc) · 1.02 KB
/
MenuDriven.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
import java.util.Scanner;
public class MenuDriven {
public static void main(String[] args) {
System.out.println("\t\tMenu");
System.out.println("1)ADD\n2)SUB\n3)DIV\n4)MUL\n5)MOD");
System.out.println("Enter 2 numbers");
int a,b;
Scanner s=new Scanner(System.in);
a=s.nextInt();
b=s.nextInt();
s.nextLine();
System.out.println("Enter Operation");
String op=s.nextLine();
s.close();
switch (op) {
case "ADD":
System.out.println(a+b);
break;
case "SUB":
System.out.println(a-b);
break;
case "DIV":
System.out.println(a/b);
break;
case "MUL":
System.out.println(a*b);
break;
case "MOD":
System.out.println(a%b);
break;
default:
System.out.println("Invalid");
break;
}
}
}