I am doind a lab for my class and the guidlines is suppoes to consist of an input file with student names and 10 quiz grades. The output file is suppose to produce the same format as the input file but one extra column, and that extra column is suppose to represent the average of their quiz grades.
here's my input file named input1.txt:
Dill James 13 18 17 15 19 20 20 16 14 19
King Damon 18 16 11 19 12 12 13 15 18 14
Thomas Dan 13 14 12 15 18 19 19 19 12 20
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
void calculatescore();
int main ()
{
string studentname;
int total;
int q1,q2, q3, q4, q5, q6, q7 ,q8 ,q9 ,q10;
int average;
ifstream infile;
ofstream outfile;
infile.open("input1.txt");
outfile.open("output.txt");
outfile << fixed << showpoint << setprecision(2);
outfile << left << setw(20) << "Student Name"
<< setw(1) << q1
<< setw(1) << q2
<< setw(1) << q3
<< setw(1) << q4
<< setw(1) << q5
<< setw(1) << q6
<< setw(1) << q7
<< setw(1) << q8
<< setw(1) << q9
<< setw(1) << q10
<< setw(1) << average;
while (infile >> studentname);
{
{
calculatescore();
average = total / 10;
}
outfile << left << setw(10) << studentname
<< setw(1) << q1
<< setw(1) << q2
<< setw(1) << q3
<< setw(1) << q4
<< setw(1) << q5
<< setw(1) << q6
<< setw(1) << q7
<< setw(1) << q8
<< setw(1) << q9
<< setw(1) << q10
<< setw(1) << average;
}// end while
infile >> studentname>> q1>> q2>> q3>> q4>> q5
>> q6 >> q7 >> q8 >> q9 << q10;
infile.close();
outfile.close();
return 0;
}
void calculatescore()
{
int total;
int num = q1, q2, q3, q4, q5, q6, q7, q8 ,q9, q10;
string studentname;
int counter;
ifstream infile;
infile >> studentname >> q1 >> q2 >> q3 >> q4 >> q5
>> q6 >> q7 >> q8 >> q9 >> q10;
counter = 0;
while (counter < 10)
{
total = 0;
infile >> num;
while (num > 0);
{
total = total + num;
counter++;
infile >> num;
}
}
}