-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoWhiCalc.java
More file actions
50 lines (36 loc) · 1.06 KB
/
DoWhiCalc.java
File metadata and controls
50 lines (36 loc) · 1.06 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
import java.util.Scanner;
public class DoWhiCalc{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int ans,a,b,choice;
System.out.println("Enter a: ");
a = sc.nextInt();
System.out.println("Enter b: ");
b = sc.nextInt();
do{
System.out.println("1 for Addition.");
System.out.println("2 for Subtraction.");
System.out.println("3 for Multiplication.");
System.out.println("4 for Divison.");
System.out.println("5 for Exit.");
System.out.println("Enter Choice: ");
choice = sc.nextInt();
switch(choice){
case 1 : ans = a+b;
System.out.println("Addition: "+ans);
break;
case 2 : ans = a-b;
System.out.println("Subtraction: "+ans);
break;
case 3 : ans = a*b;
System.out.println("Multiplication: "+ans);
break;
case 4 : ans = a/b;
System.out.println("Divison: "+ans);
break;
case 5 : System.exit(0);
default : System.out.println("Wrong Choice! Enter choice between 1 to 5");
}
}while(true);
}
}