(Infix to Postfix) The program should convert an infix expression to an equivalent postfix expression but does not because statements are missing from the function convertToPostfix. Use the following conversion rules to help you restore the missing statements.
The rules to convert an infix expression into an equivalent postfix expression are as follows:
Suppose infx represents the infix expression an pfx represents the postfix expression. The rules to convert infx into pfx are as follows:
Initialize pfx to an empty expression and also initialize the stack.
Get the next sym, from infx.
If sym is an operand, append sym to pfx.
If sym is (, push sym into the stack
If sym is ), pop and append all the symbols from the
stack until the most recent left parenthesis. Pop and
discard the left parenthesis.
If sym is an operator:
i. Pop and append all the operators from the stack to pfx that are above the most recent left parenthesis and have precedence greater than or equal to sym.
ii. Push sym onto the stack
After processing infx, some operators might be left in the
stack. Pop and append to pfx everything from the stack.
In this program, you will consider the following (binary) arithmetic operators: +, -, *, and /. You may assume that the expressions you will process are error free.
Design a class that stores the infx and post fix strings. The class must include the following operatins:
• getInfix-storestheinfixexpression• showInfix-outputstheinfixexpression• showPostfix–outputsthepostfixexpression
Other operations that you might need are the following:
convertToPostifx – converts the infix expression into a postifx expression. The resulting postfix expression is stored in pfx.
precedence – determines the precedence between two operators. If the first operator is of higher or equal precedence than the second operator, it returns the value true; otherwise, it returns the value false.Include the constructors and destructors for automatic initialization and dynamic memory deallocation.
Test your program on the following five expressions:
A + B – C;(A + B) * C;(A + B) * (C – D);(A + ((B + C) * (E – F) – G) / (H – I); A + B * (C + D) – E / F * G + H;