ohFile.open("output.txt");
if (!ayeFile.is_open())
{
cout << "Input file not found" << endl;
system("pause");
return 0;
}
string fName;
int counter = 0;
//ayeFile >> fName;
/*cout << "First Name: " << fName << endl;
ohFile << "First Name: " << fName << endl;*/
double grade, sum = 0, avg;
while (!ayeFile.eof())
{
ayeFile >> grade;
sum = sum + grade;
counter++;
}
avg = sum / counter;
cout << "Homework Average: " << avg << endl;
ohFile << "Homework Average: " << avg << endl;
ayeFile.close();
ohFile.close();
system("pause");
return 0;
}
int main()
{
int main()
oFile.open("output.txt", ios::app);
if (!iFile.is_open())
{
cout << "Input file not found" << endl;
system("pause");
return 0; // end the program
}
string fName;
{
iFile >> fName; // iFile will work just like cin.
cout << "First Name: " << fName << endl;
oFile << "First Name: " << fName << endl;
// oFile works just like cout
}
iFile.close();
oFile.close();
system("pause");
return 0;
}
Using notes, write a program which will do the following:
1. read in an unknown number of student records where you have - first name, last name, major, and GPA
2. Output all information to both the screen and to an output file
3. After reading in data, determine the average GPA for the class
4. Output the average GPA to the screen and the output file.