In this assignment, you will implement your code using a data structure.
Design and implement an application that evaluates a postfix expression that operates on integer operands using the arithmetic operators +, -, *, and /. We are already familiar with infix expressions, in which an operator is positioned between its two operands (e.g., 2+3). A postfix expression puts the operators after its operands (e.g., 2 3 +). Keep in mind that an operand could be the result of another operation. This eliminates the need for parentheses to force precedence. For example, the following infix expression:
(5 + 2) * (8 - 5)
is equivalent to the following postfix expression:
5 2 + 8 5 - *
The evaluation of a postfix expression is facilitated by using a stack. As you process a postfix expression from left to right, you encounter operands and operators. If you encounter an operand, push it on the stack. If you encounter an operator, pop two operands off the stack, perform the operation, and push the result back on the stack. When you have processed the entire expression, there will be one value on the stack, which is the result of the entire expression.
Sample run including exception handling:
Enter a valid postfix equation ("exit to stop"): 5 3 + 2 /
Result is: 4.0
Enter a valid postfix equation ("exit to stop"): 12 8 - 6 2 + *
Result is: 32.0
Enter a valid postfix equation ("exit to stop"): 12 8 - X +
Check the input format please.
Enter a valid postfix equation ("exit to stop"): 12 8 - 6 2 +
Check the number of OPERANDS - looks like there's too many!
Enter a valid postfix equation ("exit to stop"): 12 8 - 6 2 + */
Check the number of OPERATORS - looks like there's too many!
Enter a valid postfix equation ("exit to stop"): 20 6 %
Check the input format please.
Enter a valid postfix equation ("exit to stop"): Exit
Enjoy your day!