-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjava
More file actions
71 lines (71 loc) · 2.08 KB
/
java
File metadata and controls
71 lines (71 loc) · 2.08 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.util.Scanner;
class SimpleCalculator
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("==================================");
System.out.println(" Simple clculator");
int exit = 1;
do
{
System.out.println("==================================");
System.out.println("Enter 1 for addition");
System.out.println("Enter 2 for Subtraction");
System.out.println("Enter 3 for multiplication");
System.out.println("Enter 4 for division(quotient)");
System.out.println("Enter 5 for division(remainder)");
System.out.println("==================================");
System.out.print("Enter your choice : ");
int choice = sc.nextInt();
System.out.println("==================================");
System.out.print("Enter first number : ");
int a = sc.nextInt();
System.out.print("Enter second number :");
int b = sc.nextInt();
System.out.println("==================================");
switch (choice)
{
case 1 :
{
System.out.println("You have chosen Addition");
System.out.println("Answer is : "+(a+b));
}
break;
case 2 :
{
System.out.println("You have chosen subtraction");
System.out.println("Answer is : "+(a-b));
}
break;
case 3 :
{
System.out.println("You have chosen multiplication");
System.out.println("Answer is : "+(a*b));
}
break;
case 4 :
{
System.out.println("You have chosen division(quotient)");
System.out.println("Answer is : "+(a/b));
}
break;
case 5 :
{
System.out.println("You have chosen division(remainder)");
System.out.println("Answer is : "+(a%b));
}
break;
default : System.out.println("Enter valid input");
}
System.out.println("Enter 1 to continue");
System.out.println("Enter 0 to exit");
System.out.print("Enter here : ");
exit = sc.nextInt();
}
while (exit==1);
System.out.println("==================================");
System.out.println(" Thank you..!!");
System.out.println("==================================");
}
}