In this part of the exercise you will build a simple reverse polish (or postfix) calculator. That is, one that accepts arithmetic expressions like 23 + 4 in the form 23 4 +.
You are given the following piece of pseudocode that describes an algorithm for evaluating a postfix arithmetic expression:
WHILE more symbols in expression DO
symbol <- next symbol
IF symbol is an operand THEN
push symbol onto stack
ELSE (symbol is an operator)
op1 <- pop stack
op2 <- pop stack
value <- result of applying symbol to op1 and op2
push value onto stack
ENDIF
ENDWHILE
result <- pop stack
Your program should should ask the user for a valid postfix expression and then evaluate it and print out the result.
If your calculator doesn't already, it should allow users to enter more than one expression before quitting, perhaps by asking "Do you wish to enter another?" before exiting.
© 2001 Mark Ryan and Alan Sexton