Here’s what’s expected of the code.
Create a postfix notation calculator. Postfix notation is
a particular way to order the operands and operators in an expression. In postfix notation, operands get pushed onto the stack and operators replace one or more values from the top of the stack with a new value that represents the resu of some computation. For example, the mathematical expression 5 * (3 + 4) is represented as 3 4 + 5 * in postfix notation. Your postfix notation calculator should conform to these specifications:
- Your program should evaluate each line from standard input as a postfix math expression.
- Each term in an expression is separated by whitespace.
- Each evaluation will modify the same stack or internal state.
- After each evaluation, the top of value of the stack should be displayed.
- The following operators and functions should be supported: +, -, *, /, %, ^, sqrt, sin, cos, tan, log, ln
- Operands should be stored as type double in your program.
- If an operand’s string value is e or pi, then the values of the C++ constants M_E or M_PI should be used instead.
- Assume all expressions are well formed.
You will need to include cmath to use M_E, M_PI, and various math functions.
/* Name: Postfix Calculator
Date: 10-05-17 03:06
Description: quot;Postfix notationquot; is a particular way to order the operands and operators
in an expression.