Calculate Grades
Instructions
In this project you will create a program that will calculate a student’s final grade in a course. Since you will be dealing with quiz scores you will need to use a double datatype when creating your variables that hold the quizzes and for the final grade. The program will prompt the user for 4 quiz grades and a final exam grade. You will calculate the final grade and a status on the final grade. You will display the final score and status to the user. Please create variables to hold the following values:
• Quiz 1 (double)
• Quiz 2 (double)
• Quiz 3 (double)
• Quiz 4 (double)
• Final Exam (double)
• Numeric final grade (double)
• Status (string) Note: You will have to use #include in the program
The formula for calculating the final grade is:
Numeric final grade = (((Quiz1 + Quiz2 + Quiz3 + Quiz4) / 4) * 0.8) + (FinalExam * 0.2)
86.0 = (((85.2 + 76.8 + 82.3 + 92.0) / 4) * 0.8) + (93.5 * 0.2)
The formula to calculate the status is:
Status Numeric Final Grade
Outstanding >= 84.5
Exceeds Expectation >= 73.0 and < 84.5
Poor < 73.0
Formatting the output: The numeric final grade should display with 1 decimal points precision.
This project covers methods you have learned in chapters 2 through 4.
Program Output:
This program will calculate the overall grade for a student
Please enter the score for quiz 1: 85.2
Please enter the score for quiz 2: 76.8
Please enter the score for quiz 3: 82.3
Please enter the score for quiz 4: 92.0
Please enter the score for the final exam: 93.5
The final grade for the student is: 86.0 which is a(n) (Outstanding) grade.
Press any key to continue . . .
Solution:
grade (1).cpp
#include
#include
#include
using namespace std;
int main() {
// variables to store the scores
double quiz1, quiz2, quiz3, quiz4;
doublefinalExam, finalGrade;
string status;
// prompt the user to enter the scores
cout<< “This program will calculate the overall grade for a student” <
cout<< “Please enter the score for quiz 1: “;
cin>> quiz1;
cout<< “Please enter the score for quiz 2: “;
cin>> quiz2;
cout<< “Please enter the score for quiz 3: “;
cin>> quiz3;
cout<< “Please enter the score for quiz 4: “;
cin>> quiz4;
cout<< “Please enter the score for the final exam: “;
cin>>finalExam;
cin.ignore(256, ‘\n’); // consume \n in the input
// calculate final grade and status
finalGrade = (((quiz1 + quiz2 + quiz3 + quiz4) / 4) * 0.8) + (finalExam * 0.2);
if (finalGrade>= 84.5) {
status = “Outstanding”;
} else if (finalGrade>= 73.0) {
status = “Exceeds Expectation”;
} else {
status = “Poor”;
}
// display the result
cout<
<< “The final grade for the student is: ”
<
<< ” which is a(n) (” << status << “) grade.”
<
cout<< “Press any key to continue…” <
cin.get();
}