Question
Please write the following program in c++. Please also show all outputs. This program is based on the program given below. PROGRAM REQUIRMETNS: This assignment
Please write the following program in c++. Please also show all outputs.
This program is based on the program given below.
PROGRAM REQUIRMETNS:
This assignment is based on Assignment 3 and rewrite it using multiple functions to calculate the student average and letter grade. The followings are the rules of calculating the average and letter grade. Average Score Calculation: Average Score = (Test Score 1 + Test Score 2 + Test Scores 3) /3.0 Grade Conversion Rules: rule a. If the average score is 90 or more the grade is 'A'. rule b. If the average score is 70 or more and less than 90 then check the third test score. If the third score is 90 or more the grade is 'A' otherwise the grade is 'B'. rule c. If the average score is 50 or more and less than 70 then check the average of the second and third scores. If the average of the last two is 70 or more, the grade is 'C' otherwise it is a 'D' rule d. If the average score is less than 50 then the grade is 'F'. Rounding Rule: Midpoint Rounding Calculate the grade average as a double. Round up to the next int if the fractional part is .5 or greater, otherwise truncate the fraction by casting to an int. The algorithm is: Add .5 to the average and cast the result to an int. Example: average = static_cast
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
PROGRAM REFFERENCE:
#include
int test1, test2, test3; double average, average2;
int main() {
cout << fixed << showpoint << setprecision(2);
//reads three test scores (between 0 and 100) //and calculates the average score and converts it to a letter grade.
cout << "Enter Three test scores between 0 and 100: "; cin >> test1 >> test2 >> test3; cout << endl;
//Defining Variables char grade; average = ((test1 + test2 + test3) / 3.0 + 0.5); average2 = ((test1 + test2) / 2.0 + 0.5);
static_cast
//Defining Rules:
//Rule a. if(average >= 90) grade='A';
//Rule b. else if(average >= 70) if (test3 >= 90) grade = 'A'; else grade = 'B'; //Rule c. else if (average >= 50) if (average2 >= 70) grade = 'C'; else grade = 'D';
//Rule d if(average < 50) grade = 'F'; cout << "The average score = " << round(average) << endl; cout << " Your letter grade is " << grade < }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started