Jul 4, 2014 at 4:41pm UTC
Hello
Just like my previous question this is a code i implemented to the teacher psuedocode but it doesnt process
// Name: Liat Ledder
// Email: ledder.liat@titans.easternflorida.edu
// Purpose:
// To merge the female client file and the male client file into one file containing a list
// of all clients, maintaning ID number order.
#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
int main( )
{
ifstream inFile1;
ifstream inFile2;
ofstream outFile1;
int mClientNumber, fClientNumber;
string mClientName, fClientName;
bool atLeastOneFileNotAtEnd = true;
bool inFile1Written = false;
bool inFile2Written = false;
cout << "File merge processing starting" << endl;
inFile1.open("MaleClients.rtf");
inFile2.open("FemaleClients.rtf");
outFile1.open("MergedClients.rtf");
inFile1 >> mClientNumber;
inFile1 >> mClientName;
inFile2 >> fClientNumber;
inFile2 >> fClientName;
while ( atLeastOneFileNotAtEnd == true )
{
if(inFile1.eof())
{
if(inFile2Written == false)
{
outFile1 << fClientNumber << " ";
outFile1 << fClientName << endl;
inFile2Written = true;
}
}
else if (inFile2.eof())
{
if (inFile1Written == false)
{
outFile1 << mClientNumber << " ";
outFile1 << mClientName << endl;
inFile1Written = true;
}
}
else if (mClientNumber < fClientNumber)
{
outFile1 << mClientNumber << " ";
outFile1 << mClientName << endl;
inFile1Written = true;
}
else
{
outFile1 << fClientNumber << " ";
outFile1 << fClientName <<endl;
inFile2Written = true;
}
if(!(inFile1.eof()) && (inFile1Written == true))
{
inFile1 >> mClientNumber;
inFile1 >> mClientName;
inFile1Written = false;
}
if(!(inFile2.eof()) && (inFile2Written == true))
{
inFile2 >> fClientNumber;
inFile2 >> fClientName;
inFile2Written = false;
}
if (inFile1.eof()&& inFile2.eof())
{
atLeastOneFileNotAtEnd = false;
}
}
inFile1.close();
inFile2.close();
outFile1.close();
cout << "Merging Complete" << endl;
system("PAUSE");
return 0;
}
Last edited on Jul 4, 2014 at 4:50pm UTC
Jul 4, 2014 at 5:01pm UTC
I suggest you get one problem fixed, then move on to the next program. You'll likely find that you have the same problem as your first post.