Project #4
Due Dates: Phase 1: beginning
of class, Tuesday, November 9, 2004
complete project: beginning
of class, Tuesday, November 16, 2004
The objective in this project is to develop a translator that
converts an infix arithmetic expression into a postfix (RPN)
expression. This project depends on material from Lewis & Chase,
Chapter 6, as well as the handout Translating Arithmetic Expressions
to Postfix ("Reverse
Polish" or RPN)
Form.
The textbook provides a class PostfixEvaluator,
which contains some constants and methods, and an application Postfix,
which reads RPN expressions from the keyboard and evaluates them. The
handout provides an algorithm for translating an infix expression into
an RPN expression.
Phase 1:
- Modify the class so that it uses your linked stack instead of an
array stack; retest the class using the Postfix
application
- Add a stub for a new method String
toPostfix(String infix)
which takes an infix expression as input and returns a postfix
expression
- Document the revised PostfixEvaluator
class using javadoc
Phase 2:
- Implement the toRPN method
using the final algorithm, with precedences and parentheses
- Modify the Postfix
application so that instead of reading a postfix expression, it
- reads an infix expression
- sends the expression to toRPN and
displays the postfix result
- evaluates the postfix expression as in the existing Postfix