-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwitch.java
More file actions
27 lines (26 loc) · 839 Bytes
/
Switch.java
File metadata and controls
27 lines (26 loc) · 839 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
26
27
import java.util.*;
public class Switch {
public static void main(String[] args) {
double a,b,c;
Scanner in = new Scanner(System.in);
System.out.println("Enter operater(+,-,*,/)");
char ch= in.next().charAt(0);
System.out.println("Enter valuse of a and b");
a=in.nextDouble();
b=in.nextDouble();
switch(ch){
case '+':c=a+b;
System.out.println("Result: "+a+"+"+b+"="+c);
break;
case '-':c=a-b;
System.out.println("Result: "+a+"-"+b+"="+c);
break;
case '*':c=a*b;
System.out.println("Result: "+a+"*"+b+"="+c);
break;
case '/':c=a/b;
System.out.println("Result: "+a+"/"+b+"="+c);
break;
}
}
}