Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The course records are in a file that will serve as the input file. The input fi

ID: 3621443 • Letter: T

Question

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 first name, then one space, then ten quiz scores all in 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 students ten quiz scores.

These are the names of the students and their quiz scores:

jones joe 85 88 92 75 81 77 92 79 95 100
jones bob 71 72 73 74 75 76 77 78 79 80
kay michelle 75 76 77 78 79 80 81 82 83 88
kono darell 55 56 57 58 59 60 61 62 63 64
abel anna 77 88 99 100 78 79 84 85 86 61

Explanation / Answer

please rate - thanks

#include <iostream>
#include <fstream>
using namespace std;
int main()
{int i,a[10],sum;
ifstream in;
ofstream out;
double average;
string first,last;
in.open("input.txt");       
if(in.fail())           
   { cout<<"input file did not open please check it ";
   system("pause");
   return 1;
   }
out.open("output.txt");        
in>>last;
while(in)
{in>>first;
sum=0;
for(i=0;i<10;i++)
   {in>>a[i];
    sum+=a[i];
   }
average=sum/10.;
out<<last<<" "<<first<<" ";
for(i=0;i<10;i++)
   out<<a[i]<<" ";
out<<average<<endl;
in>>last;
}
      
out.close();
in.close();
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote