38 lines
925 B
Java
38 lines
925 B
Java
|
|
import java.io.BufferedReader;
|
|
import java.io.InputStreamReader;
|
|
|
|
/**
|
|
* MyApp is the driver class for Calculator
|
|
*/
|
|
public class MyApp
|
|
{
|
|
/**
|
|
* main is the entry point of the program
|
|
*/
|
|
public static void main (String args[])
|
|
{
|
|
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
|
Calculator myCalc = new Calculator();
|
|
|
|
/* loop reading input lines until the user is finished */
|
|
for (;;)
|
|
{
|
|
System.out.println("Enter rational RPN expression (enter empty line to quit):");
|
|
String line;
|
|
try
|
|
{
|
|
line = in.readLine();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
System.out.println("Problem reading a line!");
|
|
return;
|
|
}
|
|
if (line.equals(""))
|
|
break;
|
|
myCalc.run(line);
|
|
}
|
|
}
|
|
}
|