You are to write a C++ program to compute the final grade for acourse. Student I
ID: 3615474 • Letter: Y
Question
You are to write a C++ program to compute the final grade for acourse. Student ID numbers, which should be pure numerical numberand may be as large as nine digits, identifies students. The finalgrade is composed of two parts, homework average counts for 40percent and test average counts for 60 percent. There are twotests; each has maximum points of 100. There are seven homeworkassignments, with maximum points of 25, 30, 40, 50, 35, 35 and 50respectively. Homework average is computed by adding all thehomework scores together then divide by maximum possible points.The final grade needs to be converted to letter grade, and thescale is listed below:
>90 A
80 – 89.9 B
70 – 79.9 C
60 – 69.9 D
<60 E
After each student's grade is determined, the program performs astatistics on the entire class by finding out how many A's, B's,C's, D's and E's in the class.
The program should read input from data file "prg5data.txt",which is included in the assignment folder. The output should go tofile "prg5out.txt", which is to be created, and should haveinformation for each student followed by class statistics. Theaverage and final scores should always be printed with one decimalplace.
The following is a sample data file, in the order of student id,two test scores, and seven homework scores on each line:
123456789 77.2 88.3 22 28 35 45 33 35 40
234567890 97.5 90 25 30 38 48 34 35 50
345678901 82.4 77.5 22.5 27 35.5 44 35 33 48
And the following is the sample output file:
STUDENTID HW AVE TESTAVE FINALSCORE GRADE
123456789 89.8 82.8 85.6 B
234567890 98.1 93.8 95.5 A
345678901 92.5 80.0 85.0 B
Number of A's: 1
Number of B's: 2
Number of C's: 0
Number of D's: 0
Number of E's: 0
You are required to solve this problem usingarray and struct and also file I/O that were learned in thiscourse. You need declare a structure studentTypeto collectively manager each student's data, and an arrayof 30 students to manager a class of maximum 30 students.Each student should have studentID, hwAve, testAve, finalScore, anarray of 2 test scores, and an array of 7 homework scores.
The following are functions that you must implement for the mainsteps:
int getInput ( studentType [], int ); //send over array of 30 students to get input
// return how many students are read
// open input file should be done here
void process ( studentType [], int ); // sendover number of students really stored in
// array to calculate grade for each student
void display ( cost studentType [], int); // send overnumber of students really
// stored in array to display
Explanation / Answer
please rate - thanks #include #include #include using namespace std; struct student { string id; double hwavg; double tstavg; double avg; double test[2]; double hw[7]; } stu[30]; void getinput(student stu[],int& n) {int i; ifstream in; in.open("prg5data.txt"); //open file if(in.fail()) //is it ok? { coutstu[n].id; while(in) { for(i=0;i>stu[n].test[i]; for(i=0;i>stu[n].hw[i]; n++; in>>stu[n].id; } in.close(); } void process ( student stu[], int n) {double tot; int i,j; int totHW=275; for(j=0;jRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.