Problem #5
Calculator of Doom
In-fix is the notation for writing arithmetic expressions that is normally used. An operand is written, then an operator, then another operand.
Post-fix is another notation for writing arithmetic expressions. Using post-fix, two operands are written, then the operator that will work on them is written. For example:
In-fix Post-fix
====== ========
3 x 4 3 4 x
3 / 4 3 4 /
3 + 4 3 4 +
3 - 4 3 4 -
Post-fix is a bit odd looking but has the advantage of never needing parenthesis.
Write a program that acts as a post-fix calculator with the following operators and controls:
addition
subtraction
multiplication
division
clear
exit
When program is run, the calculator will wait for the user to enter two operands, then the operator. The expression will be evaluated and the answer displayed. At that point, the user can chose to continue, clear or exit. If the user choses to continue, the previous answer serves as the first operand and the user is asked to enter another operand and an operator. If the user choses to clear, the previous answer is discarded and the user is asked to enter two operands and an operator. If the user choses to exit, the program halts.