The purpose of this assignment is to get you acquire skills with input and outpu
ID: 3627098 • Letter: T
Question
The purpose of this assignment is to get you acquire skills with input and output files and functional decomposition by using functions to implement your solution to the problem Create the following input data file (data.txt) containing a pair of student id and the Anal course average for an unknown number of students: 111 89.5 222 78.9 333 56.5 444 92.6 555 77.7 666 82.7 Write a program to perform the following tasks: Declare in the main function three arrays ini id[40]. float avg[40]. and char grade[40]. Open the above data file and then use the while loop to read the student id in the id array and the average in the avg array. Call function find grade (id, avg, grade) to accept these three arrays as parameters and do the following: For each student, find the grade corresponding to the average. The Grade should be A if the average >89.0 else B if average > 79.0 else C if average > 69.0 else D if average > 59.0 else F Store the grade in the array grade Call function print (id, avg, grade) to produce the report shown in the output below. In this function you will need to find total number of A grades, total of Bs, Cs, Ds and Fs based on the grades found in the array grade Your output should look as follows: Your output should look as follows: STUDENT REPORT STUDENT ID AVERAGE GRADE 111 89.5 A 222 78.9 C 333 56.5 D 444 92.6 A 555 77.7 C 666 82.7 B Total As = 2 Total Bs = 1 Total Cs = 2 Total Ds = 1 Total Fs = 0 Here are the prototypes for the above two functions: void find grade (int[], float[], char[]); void print (int[], float[], char[]);Explanation / Answer
The output given has a mistake it shows 333 with avg 56.5 with grade as 'D' which should be actually 'F'. Here is code for program. Place data in file named test.dat #include #include using namespace std; int no_of_stud=0; void findgrade(int sid[],float avg[],char grade[]){ int i=0; while( i89.0 ) grade[i]='A'; else if( avg[i]>79.0 ) grade[i]='B'; else if( avg[i]>69.0 ) grade[i]='C'; else if( avg[i]>59.0 ) grade[i]='D'; else grade[i]='F'; i++; } } void print(int id[],float avg[],char grade[]){ int i=0; int A=0,B=0,C=0,D=0,F=0; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.