Question: Design and implement a class calledPostfixCalculator. Use the algorithm given on page 374 to evaluate postfix expressions, as entered into the calculator. Use only the
Design and implement a class calledPostfixCalculator. Use the algorithm given on page 374 to evaluate postfix expressions, as entered into the calculator. Use only the operators +, -, *, %, and /. Assume that the postfix expressions have single digit numbersin the expression and are syntactically correct. This means that the expressions will have already been converted into correct postfix form.The PostfixCalculatorshould notconvert from infix to postfix form.In order to test the PostfixCalculator, it will be necessary to manuallyconvert your test expressions into postfix form before entering them into the PostfixCalculator. Algorithim: For( each character ch in the string) {
if(ch is an operand) {
push value that operand ch represents on stack
} else {
//ch is an operator named op
//evaluate and push the result
operand2 = pop the top of the stack
operand1 = pop the top of the stack
result = operand1 op operand2
push result onto stack
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
