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

Write an infix to postfix converter as described in chapter 6. Use code from cha

ID: 3673841 • Letter: W

Question

Write an infix to postfix converter as described in chapter 6. Use code from chapter 7 to implement a stack (can be array based or linked based).

Assume:

            1. variables are single character from a to z (lowercase)

            2. There are no unary minus or plus

            3. There are no spaces

Put in error detection that would detect variables together (like bb+c), operators together (like b++c), or mismatched parenthesis. It is recommended to use a Boolean, like validExp, to signal that the expression is incorrect. Also recommended to use another Boolean to keep track of the type of character gotten from the string, like previousOperand for the fact that a variable had been processed and the next should be an operator: note, with parenthesis, check the previousOperand but do NOT set it. For instance, (a+b) is valid while a(+b) is not – checking that the previousOperand is true would generate an error for a(+b).

The program should input the infix expression, then either print an error or print the postfix expression. Use C++ and do not write anything if you are not going to fallow the rules and just copy paste from the web. Thanks. I really need your help.

Textbook is Data Abstraction and Problem solving by C++ 6th edition

Explanation / Answer

Infix to postfix: #include #include #include const int MAX = 80 ; class infixtopostfix { private : char target[MAX], stack[MAX] ; char *s, *t ; int top ; public : infix( ) ; void setexpression ( char *str ) ; void push ( char c ) ; char pop( ) ; void convert( ) ; int setpriority ( char c ) ; void show( ) ; } ; infixtopostfix :: infixtopostfix( ) { top = -1 ; strcpy ( target, "" ) ; strcpy ( stack, "" ) ; t = target ; l = "" ; } void infixtopostfix :: setexpression ( char *str ) { l = str ; } void infix :: push ( char c1 ) { if ( top == MAX ) cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote