Question: Using stacks, write an implementation that contains classes to evaluate a Prefix expression. Your implementation should include: - A PreFixEvaluator class. - A PreFixConsole Class.

Using stacks, write an implementation that contains classes to evaluate a Prefix expression. Your implementation should include:

- A PreFixEvaluator class.

- A PreFixConsole Class.

- Any exception classes you need to write

You should model your classes after the classes in the text used for Postfix Evaluation, pages 137 140.

You should use the algorithm given in the Prefix Notation and Expressions Handout.

My advice is to first assume a valid prefix expression and get your implementation to work with that assumption. Next, go back and add exception handling and test with invalid prefix expressions. Your final implementation should return the result of a valid prefix expression or output an error message indicating what is wrong with the prefix expression.

You can use either the ArrayBoundedStack class or the LinkedStack class in your implementation. (DO NOT JUST REVERSE THE PREFIX EXPRESSION TO FORM A POSTFIX EXPRESION AND EVALUATE USING THE CODE IN THE BOOK. THIS WILL RESULT IN 0 CREDIT.)

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!