Build a java applet to do integer infix expression
processing. Design an interface with an “expression” text field, and buttons to
calculate and clear. (You may use any interface
as long as it is simple, elegant and intuitive). You should be able to detect errors: “illegal
character”, “missing operand”, “mismatched parentheses”, “missing operator”, “division by zero”. Blanks
are allowed anywhere between operators and operands.
This project should have the following classes:
- The
GUI – may be the applet itself
- A
static precedence/arithmetic class – to determine which of two operators
has higher precedence. A method to “do
one operation and return result” is also handy.
- A
stack that takes a generic data type. You will need two instances of this,
one for String or some other char wrapper, and one for Integer (the int wrapper).
- Something
like StringTokenizer to
enable you to retrieve tokens from the input String. (You may use the java class).
- A StackException to be thrown on overflow or underflow.
- Provision
for Error handling. A class that
returns a string for an error code is one way to do it.