Construct a C++ grading program for a class with the following grading policies:
ID: 3878976 • Letter: C
Question
Construct a C++ grading program for a class with the following grading policies:-
a. There are two quizzes, each quizzes is worth 10 points.
b. There is one mid semester test and one final test, each is worth 100 points.
c. The final test accounts for 50 percent of the grade, the mid semester test accounts for 25 percent of the grade and the two quizzes together count for another total 25 percent.
Grading system is as follows:-
>90 A
>=80 and <90 B
>=70 and <80 C
>=60 and <70 D
<60 E
The program should read in the student's scores and output the student's record, which consists of two quiz and two exam scores as well as the student's average numeric score for the entire course and the final letter grade. Define and use a structure for the student record.
Use these functions to create the program.
void ENTER(S& st); // Asks the user to input for one student and sets the structure variable members.//
void A(S& st); //use this to determine the numeric average and letter grade.//
void R(const S st); //outputs the student record.
Sample Output(User input is in BOLD.):
Sample data for the test run(User input is in BOLD.):
1 7 10 90 95
2 9 8 90 80
3 7 8 70 80
4 5 8 50 70
5 4 0 40 35
Output:
input student #: 1
input the two quiz scores
7 10
Input midsemester test and final test scores
90 95
input student #: 2
input the two quiz scores
9 8
Input midsemester test and final test scores
90 80
input student #: 3
input the two quiz scores
7 8
Input midsemester test and final test scores
70 80
input student # : 4
input the two quiz scores
5 8
Input midsemester test and final test scores
50 70
input student #: 5
input the two quiz scores
4 0
Input midsemester test and final test scores
40 35
Record for student # 1
Quiz scores : 7 10
Midsemester test and final test scores: 90 95
Average: 91.25
Letter grade earned is A
Record for student # 2
Quiz Scores: 9 8
Midsemester test and final test scores: 90 80
Average: 83.75
Letter grade earned is B
Record for student # 3
Quiz Scores: 7 8
Midsemester test and final test scores: 70 80
Average: 76.25
Letter Grade earned is C
Record for student 4
Quiz Scores: 5 8
Midsemester test and final test scores: 50 70
Average: 63.75
Letter Grade earned is D
Record for student #5
Quiz Scores: 4 0
Midsemester and final test scores: 40 35
Average: 32.5
Letter Grade is earned is F
Explanation / Answer
Given below is the code for the question.
Please do rate the answer if it was helpful. Thank you
#include <iostream>
using namespace std;
struct S
{
int id;
int quiz1, quiz2;
int mid, finals;
double average;
char grade;
};
void ENTER(S& st); // Asks the user to input for one student and sets the structure variable members.//
void A(S& st); //use this to determine the numeric average and letter grade.//
void R(const S st); //outputs the student record.
int main()
{
S st[5];
for(int i = 0; i < 5; i++)
{
ENTER(st[i]);
A(st[i]); //calcualte average and grade
}
for(int i = 0; i < 5; i++)
R(st[i]);
}
void ENTER(S& st) // Asks the user to input for one student and sets the structure variable members.//
{
cout << "Input student #: ";
cin >> st.id;
cout << "Input the two quiz scores" << endl;
cin >> st.quiz1 >> st.quiz2;
cout << "Input midsemester test and final test scores" << endl;
cin >> st.mid >> st.finals;
cout << endl;
}
void A(S& st) //use this to determine the numeric average and letter grade.//
{
double quizAvg, midAvg, finalsAvg;
// 25% is from quiz
quizAvg = 0.25 * (st.quiz1 + st.quiz2) / 20.0;
//25% from mid test
midAvg = 0.25 * (st.mid/100.0);
//50% from final test
finalsAvg = 0.50 * (st.finals / 100.0);
//store the weighted average in student rec, multiply by 100 to make percentage
st.average = 100 * (quizAvg + midAvg + finalsAvg);
if(st.average >= 90)
st.grade = 'A';
else if(st.average >= 80)
st.grade = 'B';
else if(st.average >= 70)
st.grade = 'C';
else if(st.average >= 60)
st.grade = 'D';
else
st.grade = 'F';
}
void R(const S st) //outputs the student record.
{
cout << "Record for student #" << st.id << endl;
cout << "Quiz scores: " << st.quiz1 << " " << st.quiz2 << endl;
cout << "Midsemester test and final test scores: " << st.mid << " " << st.finals<< endl;
cout << "Average: " << st.average << endl;
cout << "Letter grade earned is " << st.grade << endl << endl;
}
output
=====
Input student #: 1
Input the two quiz scores
7 10
Input midsemester test and final test scores
90 95
Input student #: 2
Input the two quiz scores
9 8
Input midsemester test and final test scores
90 80
Input student #: 3
Input the two quiz scores
7 8
Input midsemester test and final test scores
70 80
Input student #: 4
Input the two quiz scores
5 8
Input midsemester test and final test scores
50 70
Input student #: 5
Input the two quiz scores
4 0
Input midsemester test and final test scores
40 35
Record for student #1
Quiz scores: 7 10
Midsemester test and final test scores: 90 95
Average: 91.25
Letter grade earned is A
Record for student #2
Quiz scores: 9 8
Midsemester test and final test scores: 90 80
Average: 83.75
Letter grade earned is B
Record for student #3
Quiz scores: 7 8
Midsemester test and final test scores: 70 80
Average: 76.25
Letter grade earned is C
Record for student #4
Quiz scores: 5 8
Midsemester test and final test scores: 50 70
Average: 63.75
Letter grade earned is D
Record for student #5
Quiz scores: 4 0
Midsemester test and final test scores: 40 35
Average: 32.5
Letter grade earned is F