I got stuck in this program and dont know how to start to phase 2, i finish phase 1 quite good bt i dont understand connection phase 1 and phase 2. so i hope some one can help me pls, thank you very much.....

phase 2:Expand Phase 1 to translate the typical infix statements to postfix. The postfix should be printed out and then calculated. For example: (3+5)*9? should output 3 5 + 9 * = 72.

and i finish my phase 1

header.h

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

class Lexeme
{
private:
	string Lex;
	string type;

public:


	Lexeme();
	string getLex ();
	string gettype ();
	void setLex (string);
	void settype (string);
};

main.cpp

#include "TheHeader.h"
#include <stack>
void ReadFile(); 

int main ()
{
	ReadFile();
	return 0;
}
void ReadFile()
{
	char a;
	string str = "";
	Lexeme temp;
	stack <Lexeme> name;

	ifstream file ("sample.txt",ios::in);
	if(!file)
	{
		cout<<"Unable to open the file!!!" <<endl;
		exit(1);
	}
	file >> a;

	while (file)
	{
		if (a == '/' ||a == '*' ||a == '+' ||a == '-' ||a == ';' ||a == '^'||a == '='||a == '('||a == ')')
		{cout << a << " symbol" << endl ;
		str = a;
		temp.setLex(str);
		temp.settype("SYMBOL");
		name.push(temp);
		file >> a;
	}

	else {str = a;file >> a;
	while( a >= '0' && a <= '9' || a == '.')
	{

	str.append(1,a);
	file >> a;
	}
		temp.setLex(str);
		temp.settype("NUMBER");
		name.push(temp);
		cout << str << " number" <<endl ;
		str = "";
	}
	}

	file.close();
}

header.cpp

#include "TheHeader.h"



Lexeme::Lexeme()
{
Lex = "";
type ="";
}
	string Lexeme::getLex ()
	{
		return Lex;
	}
	string Lexeme::gettype ()
	{
		return type;
	}
	void Lexeme::setLex(string b)
	{
		Lex = b;
	}
	void Lexeme::settype (string c)
	{
		type = c;
	}

hope someone can guide me to right direction, i will spend all my time of this weekend to work on this problem only
thank youi

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.