I'm having a lot of problems writing a program to open a file listing the grades of 4 students, all listed next to their names, and outputting an appended version of the file with the average of the scores next to the numbers on each line.
it goes something like this:
[here is the input]
test_ line_ 10 20 30 40 50 60 70 80 90 100
Price Betty 40 50 60 70 60 50 40 30 60 90
Good John 60 70 80 90 50 60 90 90 100 90
Smith Charles 70 80 90 60 70 60 80 90 90 90
Spangenberg Ward 70 70 80 90 70 80 90 80 70 60
[After]
test_ line_ 10 20 30 40 50 60 70 80 90 100 55.00
Price Betty 40 50 60 70 60 50 40 30 60 90 55.00
Good John 60 70 80 90 50 60 90 90 100 90 78.00
Smith Charles 70 80 90 60 70 60 80 90 90 90 78.00
Spangenberg Ward 70 70 80 90 70 80 90 80 70 60 76.00
I have to use at least one function that has file streams as all or some of its arguments.
Here's what I have so far, and am confused about where to go from here:
#include <fstream>
#include <iostream>
#include <cstdlib>
using namespace std;
void grade_update(ifstream& student_grades, ofstream& avg_grade, double avg);
int main()
{
ifstream in_put;
ofstream out_put;
in_put.open("gradeBook.txt");
if (in_put.fail())
{
cout << "Input file opening failed.\n";
exit(1);
}
out_put.open("gradeBook2.txt", ios::app);
if (out_put.fail())
{
cout << "Output file opening failed.\n";
exit(1);
}
in_put.close();
out_put.close();
system("Pause");
return 0;
}
void grade_update(ifstream& student_grades, ofstream& avg_grade, double avg);
{
}