I know that I can use istringstream to match the text from one text file to another but I just cant wrap my head around how that would look in code. I need help with this because my project is due tomorrow night and I need to spen the day with my mom. its her 85th birthday and its her first birthday since my dad passed. can someone please help me?
//-----------------------------main body
int main()
{
cout << "Welcome to the GradeCaculator Deluxe." << endl;
cout << "Enter the name of the STUDENT file including the extension :: " << endl;
getline (cin, StudentTextFile);
cout << StudentTextFile << endl;
cout << "Enter name of the CLASS HOURS file including the extension :: " << endl;
getline (cin, ClassHoursTextFile);
cout << "Enter name of the DATA file including the extension :: " << endl;
getline (cin, DataTextFile);
cout << "Enter name of the LOG file including the extension :: " << endl;
getline (cin, LogTextFile);
GetStudentList ();
// GetClassHours ();
OpenOutputFile ();
// OpenLogFile ();
}//end main
//--------GetStudentList
string GetStudentList()
{
string FirstName;
string LastName;
int StudentId;
int NumberOfGrades;
string ClassName;
char Grade;
int Index = 0;
int LineIndex = 0;
ifstream StudentFile;
student MyStudents;
grades MyGrades;
StudentFile.open(StudentTextFile.c_str());
if(!StudentFile.is_open())
{
exit(EXIT_FAILURE);
}
GetClassHours ();
while (StudentFile >> FirstName >> LastName >> StudentId >> NumberOfGrades)
{
MyStudents.FirstName = FirstName;
MyStudents.LastName = LastName;
MyStudents.StudentId = StudentId;
MyStudents.NumberOfGrades = NumberOfGrades;
for (int Index = 0; Index < NumberOfGrades; ++Index)
{
(StudentFile >> ClassName >> Grade);
//======================================================
///======this is where I think the math search should go
//======================================================
//int Grades MyHours [15];
ifstream HoursFile;
//struct grades MyGrades;
//cout <<"Enter the file name for the list of Class Hours, including the extension::" << endl;
//getline(cin, File2);
HoursFile.open(ClassHoursTextFile.c_str());
if(!HoursFile.is_open())
{
exit(EXIT_FAILURE);
}
TextToWrite = "Hours.txt successfully opened for reading.\n";
OpenLogFile (TextToWrite);
return TextToWrite;
}//end GetClassHours
//-------OpenOutputFile
string OpenOutputFile()
{
ifstream OutputFile;
OutputFile.open(DataTextFile.c_str());
if(!OutputFile.is_open())
{
exit(EXIT_FAILURE);
}
TextToWrite = "Data.txt has been successfully opened for reading.\n";
OpenLogFile (TextToWrite);
return TextToWrite;
}//end GetClassHours
//-------OpenLogFile
string OpenLogFile(string TextToWrite)
{
ofstream OutLogFile;
OutLogFile.open(LogTextFile.c_str());
if (!OutLogFile.is_open())
{
exit(EXIT_FAILURE);
}//end if
cout << "The file has been successfully opened for reading.\n";
//string TextToWrite = "andy";
OutLogFile << TextToWrite << endl;
OutLogFile.close();
return TextToWrite;
}//end OpenLogFile
//int OpenLogFile(ofstream& OutLogName, string& LogFileName, string TextToWrite)
//{
//ofstream OutLogName;
//OutLogName.open(LogTextFile.c_str());
//if (!OutLogName)
//{
//cout << "File FAILED to open....Program Terminated" << endl;
//return 1;
//}
//OutLogName << TextToWrite << endl;
//return 0;
//}//end OpenLogFile
//======================================================
///======this is where I think the math search should go
//======================================================
but i'm not clear on what your searching.
Last name & first
or
StudentId
or maybe both
I need to search for a match of course numbers and then get the credit hours of one and calculate the GPA based on other info. I'm gonna try the == operator.