Student Grade Statics Use functions to determine the number of letter grades fro
ID: 3699391 • Letter: S
Question
Student Grade Statics Use functions to determine the number of letter grades from a list of students' number grades. The requirements are given 1) Initialize the variables, countGradeA, countGradeB, countGradeD, countGradeF to 0. count Gradec 2) Display error message if necessary Validate the input data for the number of students in the class. 3) Read a number grade. If the number grade is in between 100-90, for example, then increment the countGradeA count and so on and so forth for all other grades. Letter grades are determined by the following - 90 100 A 80-89 70-79 60-69 0-59 4) Repeat Steps 2 and 3 for each number in the list 5) Print out the results which shows the counts for each grade. The following functions should be defined/implemented and called in main) int getNumberofstudents //make sure to validate number of students void Initialize(ints countGradeA, ints countGradeB, ints countGradec, int& countGradeD, int& countGradeF) ; void getNumberGrade (ints grade): //make sure to valid the grade. void classifyGrades (int grade, ints countGradeA, int&countGradeB;, int& countGradec, int& countGradeD, int& countGradeF); void printResults (int countGradeA, int countGradeB, int countGradec, int countGradeD, int countGradeF) ;Explanation / Answer
#include<iostream.h>
#include<conio.h>
int getNumberOfStudents()
{
int x;
do
{
cout<<" Please enter number of students";
cin>>x;
if(x<=0)
cout<<" Invalid Input , Re Enter";
}while (x<=0);
return x;
}
void Initialize(int& countGradeA,int& countGradeB, int& countGradeC, int& countGradeD, int& countGradeF)
{
countGradeA=0;
countGradeB=0;
countGradeC=0;
countGradeD=0;
countGradeF=0;
}
void getNumberGrade(int &grade)
{
do
{
cout<<" Please enter a number of grade between 0 and 100";
cin>>grade;
if(grade <0 || grade>100)
cout<<" Invalide grade: please re-enter";
}
while(grade <0 || grade>100);
}
void classifyGrades(int grade,int& countGradeA,int& countGradeB, int& countGradeC, int& countGradeD, int& countGradeF)
{
if(grade<60)
countGradeF++;
else if (grade<70)
countGradeD++;
else if (grade<80)
countGradeC++;
else if (grade<90)
countGradeB++;
else
countGradeA++;
}
void printResults(int countGradeA,int countGradeB, int countGradeC, int countGradeD, int countGradeF)
{
cout<<" GRADES NUMBER OF STUDENTS";
cout<<" ------ ------------------";
cout<<" A "<<countGradeA;
cout<<" B "<<countGradeB;
cout<<" C "<<countGradeC;
cout<<" D "<<countGradeD;
cout<<" E "<<countGradeF;
cout<<" Progra Ending . Good Bye!";
cout<<" -------------------------";
}
void main()
{
clrscr();
int countGradeA,countGradeB,countGradeC,countGradeD,countGradeF, grade;
Initialize(countGradeA,countGradeB,countGradeC,countGradeD,countGradeF);
cout<<" Grade Statics";
cout<<" ------------------------------";
int student=getNumberOfStudents();
for(int i=0;i<student;i++)
{
getNumberGrade(grade);
classifyGrades(grade,countGradeA,countGradeB,countGradeC,countGradeD,countGradeF);
}
printResults(countGradeA,countGradeB,countGradeC,countGradeD,countGradeF);
getch();
}