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

please help me its compiling but totally its not what i want. i have to convert

ID: 3543326 • Letter: P

Question

please help me


its compiling but totally its not what i want.


i have to convert the infix expression to post expression and pring the post fix expression .

using stack, output suppost to be infix expression and converted post expression.

please help me to check my code  please ~~~~~~~~~~~~~~~


#include<iostream>

#include<iomanip>

#include<cstring>

#include<cstddef>



using namespace std;



const char SIZE=100;


class convert

{

public:

        convert();

        bool isempty()const;

        bool isfull()const;

        void push(char let);

        void pop(char &element);

   

int num;

bool isempty();

        bool isfull();

         void print();

        void result(convert &post);

private:

        char data[SIZE];

        int top;

};


convert::convert()

{

        top=-1;

        num=top;

}




void convert::push(char let)

{

  if(isfull())

  {

cout<<"Error."<<endl;

}

else

        {

                top++;

                data[top]=let;

                num=top;

        }


}

void convert::pop(char &element)

{

        if(isempty())

                cout<<"Error"<<endl;

        else

        {

                num=top;

                element=data[top];

                top--;

                

        }

}


bool convert::isempty()

{

        return top==-1;


}


bool convert::isfull()

{

        return top==SIZE-1;

}



void convert::print()

{      

  for(int i=0;i<=top;i++)

        cout<<data[i];

}


void convert::result(convert &post)

{

        int i;

        int a,b,c;

        char op;

        int res=0;

        int loop=strlen(post.data);

        for(i=0;i<=loop;i++)

{

        if(post.data[i]=='+'||post.data[i]=='-'||post.data[i]=='*'||post.data[i]=='/')

        {

                pop(op);

                a=op-48;

                pop(op);

                b=op-48;

                if (post.data[i]=='+')

                        c=a+b;

                else if (post.data[i]=='-')

                        c=a-b;

                else if (post.data[i]=='*')

                        c=a*b;

                else c=a/b;


                op=c+48;

                push(op);


        }

        push(post.data[i]);


}

pop(op);

res=op-48;

cout<<res<<endl;


};


Explanation / Answer

you just need to put two stacks thats it