Question: Impliment an RPN calculator class,RpnCalc, supporting the operators+,-,*',/; the class should have a method called eval() that takes a string containing the expresion to be
Impliment an RPN calculator class,RpnCalc, supporting the operators"+","-","*',"/"; the class should have a method called eval() that takes a string containing the expresion to be evaluated and return a double. Token in the expresion should be separeted by a white space. The driver program for the class is provided below . The driver will invoke the eval()method with a specific expression-you are to write the RPNCalc class,run the driver program,and provided the result answer below
public class RPNCalcDriver {
public static void main(String[] args){
String expr = "1 2 3 4 5 6 7 8 9 + - * /"
RPNCalc cc = new RPNCalc();
double val = cc.eval(expr);
System.out.printf('Expression<%s> =%f/n",expr,val);
}
}
When implimanting RPNCalc you may use the JCL java.util.Stack class rather than write your own .
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
