-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculater.java
More file actions
51 lines (44 loc) · 1.57 KB
/
Calculater.java
File metadata and controls
51 lines (44 loc) · 1.57 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
import java.util.*;
public class Calculater {
public static void main(String[]args){
while (true) {
Scanner scan = new Scanner(System.in);
System.out.print("Enter the first number: ");
double num1 = scan.nextDouble();
System.out.print("Enter the second number: ");
double num2 = scan.nextDouble();
System.out.println("Select operation:");
System.out.println("1. Addition (+)");
System.out.println("2. Subtraction (-)");
System.out.println("3. Multiplication (*)");
System.out.println("4. Division (/)");
System.out.println("5. Exit");
System.out.println("Choose the options");
double Choose = scan.nextInt();
if(Choose==1){
double Result=num1+num2;
System.out.println(Result);
}
else if(Choose==2){
double Result=num1-num2;
System.out.println(Result);
}
else if(Choose==3){
double Result=num1*num2;
System.out.println(Result);
}
else if(Choose==4){
double Result=num1/num2;
System.out.println(Result);
}
else if(Choose==5){
System.out.println("Thank you");
scan.close();
return;
}
else{
System.out.println("Invalid");
}
}
}
}