Question: Develop a RPN calculator using the Stack class provided in java.util. Your class will contain a method that accepts such a string as input and
Develop a RPN calculator using the Stack class provided in java.util.
Your class will contain a method that accepts such a string as input and returns the double RPN value of the string.
Your RPN method must contain error-handling. For example, if a mathematical symbol suggests popping 2 numbers and the stack doesnt have 2, you should raise the InvalidRPNString exception (you will have to create this exception yourself). If the stack is not empty when the string is exhausted (after popping the last value), this is an error also. Anything in the string other than the 4 math symbols and valid double literals is an error. Divide by 0.0 is an error.
PLEASE DON'T COPY FROM SOMEONE ELSE'S CODE!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
