I need help to get this program done Problem : Suppose at the end of the semeste
ID: 3620278 • Letter: I
Question
I need help to get this program doneProblem : Suppose at the end of the semester, there is a file "scores.dat" recording scores each student
has earned so far from closed lab assignments (CLA), open lab assignments (OLA), quizzes, exams,
and final exam score. You can assume there are no more than 30 students. The final letter grade is
decided according to the following table based on the total points they have earned:
Total Points Final Letter Grade Total Points Final Letter Grade
>=90 A >=70, but <73 C-
>=87, but <90 B+ >=67, but <70 D+
>=83, but <87 B >=63, but <67 D
>=80, but <83 B- >=60, but <63 D-
>=77, but <80 C+ <60 F
>=73, but <77 C
In this assignment, you are asked to write a program to calculate student final letter grades as well as
the average and highest scores of CLA, OLA, quizzes, exams, and final exam scores. The final result
should be printed to the screen (standard output).
Requirements:
• At the beginning of the program, your program should give the user a prompt for the name of
the data file which contains the records of student grades.
o If file does not exist, print error message and keep asking the user to enter another file
name.
• Define a Student structure, which includes student id, scores for CLA, OLA, quizzes, exams,
final scores, total points, and letter grade.
• Define an array of Student to hold information of all students.
• Define a 1-dimensional array to store the average scores of each category.
• Define a 1-dimensional array to store the highest scores of each category.
• Functions you may need to define:
o readStudentRecord: Reading student records from a file and saving them to an array
of Student
o calculateTotalPoints: Given a student record, calculating his/her total points
o findLetterGrade: Given a total points value, find and return the corresponding final
letter grade
o calculateAverage: Calculating the average scores for each category
o calculateHighest: Calculating the highest scores for each category
o printData: Printing student information, average, and highest scores of each category.
• No global variables are allowed.
this is data table
ID CLA OLA Quiz Exam Final Total FinalGrade
c088801 10 20 5 40 25
c088802 9 12 2 31 16
c088803 8 20 3 35 20
c088804 7 18 4 36 23
c088805 3 11 4 39 25
c088806 8 17 4 36 22
c088807 4 12 4 32 18
c088808 10 17 5 31 16
c088809 8 8 3 31 19
c088810 6 9 4 39 23
c088811 8 7 5 33 21
c088812 4 11 3 31 17
c088813 9 15 2 38 20
c088814 8 12 4 20 18
c088815 6 8 1 7 15
c088816 7 17 4 36 21
c088817 8 9 2 32 18
c088818 6 18 3 37 15
c088819 7 17 4 36 23
c088820 8 19 4 35 20
Explanation / Answer
please rate - thanks #include <iostream>#include <fstream>
using namespace std;
#define MAX 30
struct grades {
string id;
int cla;
int ola;
int quiz;
int exam;
int final;
int total;
string grade;
} stu[MAX];
int readStudentRecord(grades[]);
void calculateTotalPoints(grades&);
void findLetterGrade(grades&);
void calculateAverage(grades[],double[],int);
void calculateHighest(grades[],int[],int);
void printData(grades[],double[],int[],int);
int main()
{int kt=0,sum,i,j;
double average[5];
int high[5];
kt=readStudentRecord(stu);
for(i=0;i<kt;i++)
{calculateTotalPoints(stu[i]);
findLetterGrade(stu[i]);
}
calculateAverage(stu,average,kt);
calculateHighest(stu,high,kt);
printData(stu,average,high,kt);
system("pause");
return 0;
}
void printData(grades stu[],double average[],int high[],int kt)
{
int i;
cout<<" ID CLA OLA Quiz Exam Final Total FinalGrade ";
for(i=0;i<kt;i++)
{cout<<stu[i].id<<' '<<stu[i].cla<<' '<<stu[i].ola<<' '<<stu[i].quiz<<' '<<
stu[i].exam<<' '<<stu[i].final<<' ' <<stu[i].total<<' '<<stu[i].grade<<endl;
}
cout<<"average";
for(i=0;i<5;i++)
cout<<' '<<average[i];
cout<<endl;
cout<<"high ";
for(i=0;i<5;i++)
cout<<' '<<high[i];
cout<<endl;
}
void calculateHighest(grades stu[],int high[],int kt)
{int i;
high[0]=stu[0].cla;
high[1]=stu[0].ola;
high[2]=stu[0].quiz;
high[3]=stu[0].exam;
high[4]=stu[0].final;
for(i=1;i<kt;i++)
{ if(stu[i].cla>high[0])
high[0]=stu[i].cla;
if(stu[i].ola>high[1])
high[1]+=stu[i].ola;
if(stu[i].quiz>high[2])
high[2]+=stu[i].quiz;
if(stu[i].exam>high[3])
high[3]+=stu[i].exam;
if(stu[i].final>high[4])
high[4]+=stu[i].final;
}
}
void calculateAverage(grades stu[],double average[],int kt)
{int i;
int tot[5]={0,0,0,0,0};
for(i=0;i<kt;i++)
{tot[0]+=stu[i].cla;
tot[1]+=stu[i].ola;
tot[2]+=stu[i].quiz;
tot[3]+=stu[i].exam;
tot[4]+=stu[i].final;
}
for(i=0;i<5;i++)
average[i]=tot[i]/(double)kt;
}
void findLetterGrade(grades& stu)
{int j;
int g[11]={90,87,83,80,77,73,70,67,63,60,0};
string let[11]={"A","B+","B","B-","C+","C","C-","D+","D","D-","F"};
for(j=0;j<11;j++)
if(stu.total>=g[j])
{stu.grade=let[j];
return;
}
}
void calculateTotalPoints(grades& stu)
{stu.total=stu.cla+stu.ola+stu.quiz+stu.exam+stu.final;
}
int readStudentRecord(grades stu[])
{
ifstream in;
int kt=0;
char filename[30];
cout<<"what is the name of the file you are using? ";
cin>>filename;
in.open(filename);
while(in.fail())
{ cout<<"input file did not open please check it ";
in.clear();
cout<<"what is the name of the file you are using? ";
cin>>filename;
in.open(filename);
}
in>>stu[kt].id;
while(in)
{in>>stu[kt].cla>>stu[kt].ola>>stu[kt].quiz>>stu[kt].exam>>stu[kt].final;
kt++;
in>>stu[kt].id;
}
in.close();
return kt;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.