Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help... write a program called \"infix.cpp\", that uses a stack to conver

ID: 3640858 • Letter: P

Question

Please help...
write a program called "infix.cpp", that uses a stack to convert a postfix expression to the corresponding fully-parenthesized infix expression. Consider the following examples:

the postfix expression a b + c d - * will be converted to the infix ((a + b) * (c - d))
the the postfix expression a b + will be converted to the infix (a + b)
the postfix expression a b / c d / / will be converted to infix ((a / b) / (c / d))
The program should ask the user for a postfix expression as input, and it should output the corresponding fully-parenthesized infix expression. The program should also ask the user if he/she would like to do another conversion. If so, the user should be able to enter another posfix expression; otherwise the program should terminate. Also, the stack must be implemented using a singly-linked list. The driver, infix.cpp, should include the definition and declaration files for the class STACK, stack.cpp and stack.h, respectively.

The program should do error-checking. For example, if the infix expression is invalid, the program should print an error message stating so.

Explanation / Answer

Note that the standard stack class (std::stack) was used. If you need to implement your own just make sure it's got a top(), pop() and push() methods, that's all.