Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

Rather than developing your own stack to support the project, you should use the Stack class provided in java.util. Its specification, in part, is below:

public class Stack < E> extends Vector {

public Stack();

public Boolean empty();

public Object peek() throws EmptyStackException; // returns top without popping

public Object pop() throws EmptyStackException;

public Object push(Object item);

}

PLEASE DON'T COPY FROM SOMEONE ELSE'S CODE! THANKS!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions