Write a grading program for a classwith the following grading policies. #include
ID: 3536878 • Letter: W
Question
Write a grading program for a classwith the following grading policies.
#include
<iostream>
using
namespace std;
const
int CLASS_SIZE = 5;
struct StudentRecords
{
int StudentNumber;
double Quiz1;
double Quiz2;
double MidTerm;
double Final;
double Average;
char Grade;
};
void input (StudentRecords& Student);
void ComputeGrade (StudentRecords& Student);
void output ( StudentRecords Student);
int main()
{
StudentRecords Student [CLASS_SIZE];
for(int i = 0; i < CLASS_SIZE; i++)
input (Student[i]);
for (int i = 0; i < CLASS_SIZE; i++)
{
ComputeGrade (Student [i]);
output(Student [i]);
cout << endl;
}
return 0;
}
void input (StudentRecords &Student)
{
cout<<
"Enter the student number: ";
cin>>Student.StudentNumber;
cout<<
"Enter two 10 point quizzes"<<endl;
cin>>Student.Quiz1 >> Student.Quiz2;
cout <<
"Enter the midterm and final exam grades." << "These are 100 point tests ";
cin>>Student.MidTerm >> Student.Final ;
}
void ComputeGrade (StudentRecords& Student)
{
double QuizAvg= (Student.Quiz1 + Student.Quiz2)/2.0;
double QuizAvgNormalized = QuizAvg * 10;
Student.MidTerm * 0.25 + QuizAvgNormalized * 0.25;
char LetterGrade[] = "FFFFFFDCBAA";
int index = static_cast<int>(Student.Average/10);
if(index < 0 || 10 <= index)
{
cout<<
"Bad numeric grade encountered: "<< Student.Average << endl<<"Aborting.";abort();
}
Student.Grade=LetterGrade[index];
}
void output (const StudentRecords Student)
{
cout <<
"The record for student number:" << Student.StudentNumber << endl;
cout<<
"The quiz grades are : " << Student.Quiz1 << Student.Quiz2 <<endl;
cout<<
"The midterm and exam grades are: "<<Student.MidTerm << " " << Student.Final <<endl;
cout<<
"The numeric average is: " << Student.Average << endl;
cout<<
"Grade assigned is " << Student.Grade <<endl;
}
%u3000
%u3000
%u3000
Explanation / Answer
#include<iostream>
using namespace std;
const int CLASS_SIZE = 5;
struct StudentRecords
{
int StudentNumber;
double Quiz1;
double Quiz2;
double MidTerm;
double Final;
double Average;
char Grade;
};
void input (StudentRecords &Student)
{
cout<< "Enter the student number: ";
cin>>Student.StudentNumber;
cout<< "Enter two 10 point quizzes"<<endl;
cin>>Student.Quiz1 >> Student.Quiz2;
cout << "Enter the midterm and final exam grades." << "These are 100 point tests ";
cin>>Student.MidTerm >> Student.Final ;
}
void ComputeGrade (StudentRecords& Student)
{
double QuizAvg= (Student.Quiz1 + Student.Quiz2)/2.0;
double QuizAvgNormalized = QuizAvg * 10;
Student.Average = (Student.Final*0.5 + Student.MidTerm * 0.25 + QuizAvgNormalized * 0.25);
char LetterGrade[] = "FFFFFFDCBAA";
int index = static_cast<int>(Student.Average/10);
if(index < 0 || 10 <= index)
{
cout<<"Bad numeric grade encountered: "<< Student.Average << endl<<"Aborting."; return;
}
Student.Grade=LetterGrade[index];
}
void output (const StudentRecords Student)
{
cout << "The record for student number:" << Student.StudentNumber << endl;
cout<< "The quiz grades are : " << Student.Quiz1 << Student.Quiz2 <<endl;
cout<<"The midterm and exam grades are: "<<Student.MidTerm << " " << Student.Final <<endl;
cout<<"The numeric average is: " << Student.Average << endl;
cout<<"Grade assigned is " << Student.Grade <<endl;
}
int main()
{
StudentRecords Student [CLASS_SIZE];
for(int i = 0; i < CLASS_SIZE; i++)
input (Student[i]);
for (int i = 0; i < CLASS_SIZE; i++)
{
ComputeGrade (Student [i]);
output(Student [i]);
cout << endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.