Lab 6

Stacks

February 24, 2005

Lab Partners

Everyone should work with one lab partner on this assignment.

Before Lab Begins

Create a BlueJ project named inlab6 and copy the following files into it: Driver.java

The Problem

Take a look at the Driver.java code. You will see that the CalculatorStack class is missing. Implement this class by extending java.util.Stack and adding whatever else is needed.

The purpose of CalculatorStack is to simulate a Reverse Polish Notation calculator. You may make the following assumptions about the input strings that will be passed to the calculator:

Desired Output and Grading

Evaluating 5 yields 5                       (2 points)
Evaluating 56+ yields 11                    (2 points)
Evaluating 56- yields -1                    (1 point)
Evaluating 12+34++ yields 10                (1 point)
Evaluating 1+ yields an ERROR               (2 points)
Evaluating 123+ yields an ERROR             (2 points)

What to Submit

E-mail your code to Mike Thiesen at mthiesen@gmail.com in one message. The subject of the message should be: CS221-xx inlab6 your-names. The xx is the number of your lab section.

Before Lab Ends

Delete any BlueJ projects that you created and empty the recycle bin. Thanks.