-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalcuse.java
More file actions
67 lines (64 loc) · 2.35 KB
/
calcuse.java
File metadata and controls
67 lines (64 loc) · 2.35 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
package calculator;
import java.util.Scanner;
public class calcuse {
public static void main(String[] args) {
calc obj=new calc();
Scanner sc=new Scanner(System.in);
while(true) {
System.out.println("--------------CALCULATOR---------------------");
System.out.println("1.Addition");
System.out.println("2.Subtraction");
System.out.println("3.Multiply");
System.out.println("4.Division");
System.out.println("5.Quit");
System.out.println("-----------------------------------------------");
System.out.println("Enter the choice");
int ch=sc.nextInt();
if(ch==1) {
System.out.println("------------------------------------------");
System.out.println("Enter the first number to be added");
double a=sc.nextDouble();
System.out.println("Enter the second number to be added");
double b=sc.nextDouble();
obj.addition(a,b);
System.out.println("------------------------------------------");
}
else if(ch==2) {
System.out.println("------------------------------------------");
System.out.println("Enter the first number to be subtracted");
double a=sc.nextDouble();
System.out.println("Enter the second number to be subtracted");
double b=sc.nextDouble();
obj.subtraction(a,b);
System.out.println("------------------------------------------");
}
else if(ch==3) {
System.out.println("------------------------------------------");
System.out.println("Enter the first number to be multiplied");
double a=sc.nextDouble();
System.out.println("Enter the second number to be multiplied");
double b=sc.nextDouble();
obj.multiply(a, b);
System.out.println("------------------------------------------");
}
else if(ch==4) {
System.out.println("------------------------------------------");
System.out.println("Enter the Divident");
double a=sc.nextDouble();
System.out.println("Enter the Divisor");
double b=sc.nextDouble();
obj.divide(a,b);
System.out.println("------------------------------------------");
}
else if(ch==5) {
System.out.println("------------------------------------------");
System.out.println("Thank you for using Abhika's calculator.");
System.out.println("------------------------------------------");
break;
}
else {
System.out.println("Invalid choice please enter the correct choice");
}
}
}
}