Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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(average+0.5); Functions required in the project: void gradesInput(int &s1, int &s2, int &s3) Get 3 test scores from the user and pass back 3 test scores to the calling method. ***Note that the three parameters are passed by reference. double average3Scores(int s1, int s2, int s3) Average three test scores and apply the rounding rule and return the average. You pass three test scores in the parameter list in this method. double averageLast2Scores(int s2, int s3) Average last 2 test scores and apply the rounding rule and return the average. You pass two test scores in the parameter list in this method. char toLetterGrade(double avg, double avg2, int s3) Convert average grade to letter grade according the grade conversion rules and return the letter grade. You pass average, average2 and test 3 in this method. void displayGrade(double avg, char lGrade) Display average grade and letter grade, and do not return anything. You pass averge and letter grade in your parameter list in this method.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

PROGRAM REFFERENCE:

#include #include #include using namespace std;

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(average); static_cast(average2);

//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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Differentiate 3sin(9x+2x)

Answered: 1 week ago

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago