-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsrc_Calc.java
32 lines (27 loc) · 1 KB
/
src_Calc.java
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Calc {
public static void main(String [] args) throws IOException {
//exception handling is presented in isValid
//enter data until we get the correct expression
InputData example;
while (true){
example = new InputData();
if (example.isValid()) {
break;
}
System.out.println("Not a valid expression. Enter the correct expression");
}
//the expression is displayed on the screen by the overloaded method toString
System.out.print(example);
//the calculation result
MathOperations result = new MathOperations(example);
//output the result in the same form as the entered data
if (example.getIsRom()){
System.out.println(example.intToStr(result.getResult()));
} else {
System.out.println(result.getResult());
}
}
}