-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtest.java
More file actions
59 lines (45 loc) · 1.05 KB
/
Copy pathtest.java
File metadata and controls
59 lines (45 loc) · 1.05 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
import java.io.*;
public class test {
public static void main(String[] args){
String S1 = getInput("Enter First Number: ");
String a = getInput("What do you want to do: ");
String S2 = getInput("Enter Sound Number: ");
double d1 = Double.parseDouble(S1);
double d2 = Double.parseDouble(S2);
if(a.equals("+")){
double rslt= d1 + d2;
System.out.println(rslt);
}
else if(a.equals("-")){
double rslt= d1 - d2;
System.out.println(rslt);
}
else if(a.equals("*")){
double rslt= d1 * d2;
System.out.println(rslt);
}
else if(a.equals("/")){
double rslt= d1 / d2;
System.out.println(rslt);
}
else if(a.equals("%")){
double rslt= d1 % d2;
System.out.println(rslt);
}
else
{
System.out.println("UnXpected Value");
}
}
private static String getInput(String Prompt) {
BufferedReader stdin = new BufferedReader(
new InputStreamReader(System.in));
System.out.print(Prompt);
System.out.flush();
try{
return stdin.readLine();
}catch (Exception e){
return "ERROR" + e.getMessage();
}
}
}