Question: I need a program in Java language that evaluates infix expression of unsigned integers using two stacks. This program needs exactly three classes: 1) A

I need a program in Java language that evaluates infix expression of unsigned integers using two stacks. This program needs exactly three classes:

1) A main GUI class that allows user to input an infix expression and display the results

2) a class to perform the infix expression evaluation using the following pseudocode:

tokenize the string containing the expression

while there are more tokens

get the next token

if it is an operand

push it onto the operand stack

else if it is a left parenthesis

push it onto the operator stack

else if it is a right parenthesis

while top of the operator stack not a left parenthesis

pop two operands and an operator

perform the calculation

push the result onto the operand stack

else if it is an operator

while the operator stack is not empty and

the operator at the top of the stack has higher

or the same precedence than the current operator

pop two operands and perform the calculation

push the result onto the operand stack

push the current operator on the operators stack

while the operator stack is not empty

pop two operands and an operator

perform the calculation

push the result onto the operand stack

the final result is a the top of the operand stack

3) a class for the checked exception, DivideByZero

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!