In this C++ program, you will use concepts from Chapters 1 through 3 to implement a calculator using stacks and queues in C++. In particular, your program will convert an infix expression to postfix, and then evaluate the expression.
$ ./a.out
Enter a valid infix expression: 3 + 4 * 5 / 6
The resulting postfix expression is: 3 4 5 * 6 / +
The result is: 6.33333
$ ./a.out
Enter a valid infix expression: ( 20.4 + 3 ) * -5
The resulting postfix expression is: 20.4 3 + -5 *
The result is: -117
$ ./a.out
Enter a valid infix expression: 5 + ( ( 1 + 2 ) * 4 ) - 3
The resulting postfix expression is: 5 1 2 + 4 * + 3 -
The result is: 14
$ ./a.out
Enter a valid infix expression: ( 2 + 3 ) - 7 / 9
The resulting postfix expression is: 2 3 + 7 9 / -
The result is: 4.22222
$ ./a.out
Enter a valid infix expression: 7.5 - (2 * ( 10 % 6 ) )
The resulting postfix expression is: 7.5 2 10 6 % * -
The result is: -0.5
$ ./a.out
Enter a valid infix expression: 8.4 / 2.5 * ( 3.62 + 2.04 )
The resulting postfix expression is: 8.4 2.5 / 3.62 2.04 + *
The result is: 19.0176
$ ./a.out
Enter a valid infix expression: ( -3 * 4 ) / ( 1 + 5 ) * 7
The resulting postfix expression is: -3 4 * 1 5 + / 7 *
The result is: -14
$ ./a.out
Enter a valid infix expression: 6 + 3 * 4 ^ 2 - 5
The resulting postfix expression is: 6 3 4 2 ^ * + 5 -
The result is: 49
$ ./a.out
Enter a valid infix expression: 7.4 - 3.5 / ( 2.1 * 8.2 ^ 4.7 )
The resulting postfix expression is: 7.4 3.5 2.1 8.2 4.7 ^ * / -
The result is: 7.39992
$ ./a.out
Enter a valid infix expression: 2 * 3 ^ 1.05 ^ 1.84
The resulting postfix expression is: 2 3 1.05 1.84 ^ ^ *
The result is: 6.65221
$ ./a.out
Enter a valid infix expression: ( ( 4.2 - 3.5 ) * 3.4 / 4
The resulting postfix expression is: 4.2 3.5 - 3.4 * 4
Error: Mismatched Parentheses! Program Terminated.
$ ./a.out
Enter a valid infix expression: ( 4.2 - 3.5 ) * 3.4 / 4 )
The resulting postfix expression is: 4.2 3.5 - 3.4 * 4 /
Error: Mismatched Parentheses! Program Terminated.
$ ./a.out
Enter a valid infix expression: ( ( 4.2 - 3.5 ) * 3.4 / 4 )
The resulting postfix expression is: 4.2 3.5 - 3.4 * 4 /
The result is: 0.595