In this lab you are to write a program that calculates a student's final grade and outputs the final letter grade to the console using functions. Two tests scores and one homework score will be supplied by the user. To calculate the final score assume that the tests are each worth 40% and the homework is worth 20% of the total score. You should implement and use the following two functions:
1) calcFinalScore: This function is a value-returning function whose purpose is to compute the final score for a student. It takes three parameters: test1, test2, and hw (all doubles), and returns the final score as a double.
2) printFinalScore: This function is a non value-returning function that outputs a student's final score and letter grade to the console. It takes the parameter finalScore (a double). The breakdown of letter grades is as follows: 90 or above is an A, 80 to 90 is a B, 70 to 80 is a C, 60 to 70 is a D, and less than 60 is a big fat F.
The following is skeleton code you might want to use to start your program.
#include using namespace std; // ***declare the function prototype for "calcFinalScore" here // ***declare the function prototype for "printFinalScore" here int main() { // local variables double test1, test2; // the two tests scores double hw; // the homework score double finalScore; // the student's final score cout > test1; cout > test2; cout > hw; // ***call calcFinalScore here // ***call printFinalScore here system("PAUSE"); return 0; } // ***implement calcFinalScore here // ***implement printFinalScore here The following is a sample run (bracketed bold text denotes user input): Enter the score for test #1: [87.5] Enter the score for test #2: [82] Enter the score for the homework: [95] The student's final score is: 86.8 Their final letter grade is: B
Could definitely use some help on this one
#include <iostream> using namespace std; // ***declare the function prototype for "calcFinalScore" here double calcFinalScore(double, double, double); // ***declare the function prototype for "printFinalScore" here void printFinalScore(double); int main() { // local variables // the two tests scores double test1, test2; // the homework score double hw; // the student's final score double finalScore; // read everything cout << "Enter the score for test #1: "; cin >> test1; cout << "Enter the score for test #2: "; cin >> test2; cout << "Enter the score for homework: "; cin >> hw; // ***call calcFinalScore here finalScore = calcFinalScore(test1, test2, hw); // ***call printFinalScore here printFinalScore(finalScore); return 0; } double calcFinalScore(double t1, double t2, double hw) { return 0.4 * t1 + 0.4 * t2 + 0.2 * hw; } void printFinalScore(double sc) { if(sc >= 90) { cout << "A" << endl; } else if(sc >= 80) { cout << "B" << endl; } else if(sc >= 70) { cout << "C" << endl; } else if(sc >= 60) { cout << "D" << endl; } else { cout << "F" << endl; } }
************************************************** Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.
Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.
Get Answers For Free
Most questions answered within 1 hours.