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

Write a program for the following problem using C++. You\'re given a file that c

ID: 3575204 • Letter: W

Question

Write a program for the following problem using C++. You're given a file that contains a collection of IDs and scores(type int) for an exam in your computer course. You're to compute the average of these scores and assign grades to each student according to the following rule:

If a student's score is within 10 points(above or below) of the average, assign a grade of unsatisfactory. If a student's score is more than 10 points above average, assign a grade of outstanding. If a student's score is more than 10 points below average, assign a grade of unsatisfactory.

The output from your program should consist of a labeled three column list that shows each, ID, score, and corresponding grade.

Explanation / Answer

Here is the code for you:

#include <iostream>
#include <fstream>
using namespace std;
int main()
{
string IDs[20], fileName;
int scores[20];
ifstream fin;
cout<<"Enter the name of file to read the scores: ";
cin>>fileName;
fin.open(fileName);
int count = 0;
while(!fin.eof())
{
fin>>IDs[count]>>scores[count];
count++;
}
double avg = 0.0;
for(int i = 0; i < count; i++)
avg += scores[i];
avg /= count;
cout<<"IDs Scores Grade"<<endl;
for(int i = 0; i < count; i++)
{
cout<<IDs[i]<<" "<<scores[i]<<" ";
if(scores[i] - avg > 10)
cout<<"Oustanding"<<endl;
else if(avg - scores[i] > 10)
cout<<"Unsatisfactory"<<endl;
else
cout<<"Satisfactory"<<endl;
}
}

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