input/output file

Write a program to compute numeric grades for a
course. The course records are in a file that will serve as the input
file. The input file is in exactly the following format: Each line
contains a student's last name, then on espace, then the student's
first name, then one space, then ten quiz scores all on one line. The
quiz scores are whole numbers and are separated by one space. Your
program will take its input from this file and send its output to a second
file. The data in the output file will be the same as the data in
the input file except that there will be one additional number ( of type
double ) at the end of each line. This number will be the average of
the student's ten quiz scores. If this is being done as a class
assignment, obtain the file names from your instructor. Use at least
one function that has file streams as all or some of its arguments.

I am confused on how to calculate the program. I got this for the calculating average so far
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 ifstream in_stream;
    ofstream out_stream;


    string fname, lastname;
    double avggrade;
    in_stream>>fname;

    while(in_stream>> lastname)
    {
        in_stream >> fname;
       in_stream.get(ch);
  while (ch!='\n')
    {

    }

    }


How do I make it calculate the 10 scores to find out the average?
Topic archived. No new replies allowed.