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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!