Computer Science 261
Assignment # 4
Due: Wednesday, Oct. 23
Purpose:
- To work on stacks
- To start using built-in data structures in Java
- (coming shortly): To work with interfaces
Look at the programming project on page 336 (you will also find
looking at the case study useful as well).
We don't want to do as much as is calle for in that exercise, but
we want to do some of it. Please write
- A program called StringStack which contains
- A stack of strings developed using the techniques discussed
in class
- A main program which accepts an algebraic expression from
the user (using symbols, +, -, *, /, left and right
parenthesis) and converts them to postfix (following the
discussion on pp 336 - 339), printing out the postfix form.
Input comes in from the keyboard, and only one expression need
to be translated.
- A program called StackExample which does what the previous
example does, except that you use the built-in Stack structure.
The main program will need some minimal modification, but the
stack class you wrote in the previous program will not be needed
her
- Some test cases (I may think of more, but I'll list them here:
- A + B
- A + B - C
- A*B - C
- A - B*C
- (A + B) / (A - B)
- (B - (B*B - A*C)) / (2*A)
Questions? Please ask!