My goal is to implement a C++ program that converts an infix expression into a postfix expression and then evaluates the postfix expression. I am using the Stack and Queue classes I developed with a List class (linked list) that manages the data in the stack and queue.
The output will be: Print out the infix expression, the postfix expression, and the calculated results of the expression.
I have to be able to handle the ( ) + - * / and ^ (exponential/power) operators. The precedence of ^ operator is higher than that of * and / operators.
I have attached the algorithm I am using to do this as well as the input to read in and use.
Read in the data 1 token at a time and deal with it then, do not read anything in as a string.
This must be implemented within my program and must use the stack and queue and general list I already have.© BrainMass Inc. brainmass.com April 3, 2020, 11:34 pm ad1c9bdddf
Please note that following input in your infix.txt has problem - incorrect input in the part "...*(/4)...".
Since the existing implementation returns NULL (0) value when you get the top value of an empty stack, due to which above incorrect arithmetic expression gets evaluated to an incorrect value.
Attached program has been ...
This solution is an extension to the work provided by the student in the question. Kindly use it as a guidance to develop your own solution, in case you plan to use it somewhere. Also note that GNU C++ compiler g++ version 4.3.4 was used during development of solution program.