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

3. Write a program to compute numeric grades for a course. The course records ar

ID: 3634779 • Letter: 3

Question

3. 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 one space, then the student’s first name, then one space, then five quiz scores:

ex:

anna james 100 99 98 97 96
sarah wales 45 97 32 87 25


Your program will take its input from this file and send it’s output to the screen. The output will be the name of the student and his/her average all on one line on the screen. Use the file “roster.txt”.

Explanation / Answer

Please Rate:Thanks

i hope this code will help you

#include <iostream>
#include <fstream>


#include <string>

using namespace std;
void calculate(ifstream&, ofstream&);
int main()
{
ifstream in;
ofstream out;

in.open("input.txt");

if(in.fail())
{ cout<<"Input file failed. Please try again or use another file./n";
system("pause");
return 1;
}

out.open("output.txt");
calculate(in,out);
out.close();
in.close();

system("pause");
return 0;
}

void calculate(ifstream& in, ofstream& out)

{
int i,sum,a[5];
string first,last;
double avg;
in>>first;
while(in)

{sum=0;
in>>last;
for(i=0;i<5;i++)
{in>>a[i];
sum+=a[i];
}

out<<first<<" "<<last<<" ";
for(i=0;i<5;i++)
out<<a[i]<<" ";
avg=sum/5.;
out<<avg<<endl;
in>>first;
}
}


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