Create an interpreter that repeatedly prompts the user for an arithmetic expression of the form:
NUMBER OPERATION NUMBER
Where
OPERATION = + or * or – or /
The interpreter executes the expression and prints the result. Here's a sample output:
-> 3.1 + -4.2
-1.1
-> 5 * 2
10.0
-> 2 / 4
0.5
-> quit
bye
Here's a sketch of your interpreter:
public class Interpreter {
public void controlLoop() {
// read-exec-print loop goes here
}
public String execute(String exp) {
// do arithmetic here, return result
as a string
}
}