-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitchmenu.java
More file actions
25 lines (25 loc) · 768 Bytes
/
switchmenu.java
File metadata and controls
25 lines (25 loc) · 768 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
import java.util.Scanner;
public class switchmenu
{
public static void main(String[] args)
{
Scanner sc=new Scanner (System.in);
System.out.println("add\nsub\nmul\ndiv\nenter the word to perform operation:\n");
String str=sc.nextLine();
System.out.println("enter two no: ");
int n1=sc.nextInt();
int n2=sc.nextInt();
switch(str)
{
case "add": System.out.println(n1+n2);
break;
case "sub": System.out.println(n1-n2);
break;
case "mul": System.out.println(n1*n2);
break;
case "div": System.out.println(n1/n2);
break;
default: System.out.println("invalid");
}
}
}