Question

In this lab you are to write a program that calculates a student's final grade and...

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

Homework Answers

Answer #1


#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.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In Python... Write a program that calculates a student’s final grade in this course. The program...
In Python... Write a program that calculates a student’s final grade in this course. The program should: Display a message stating its goal Prompt the user to enter a student’s average grade for the weekly assignments, grade for mid-course project and grade for final project Calculate the final grade based on these percentages... Assignments = 60% Mid-course & Final Project = 40% (20% each) A A- B+ B B- C+ C C- D+ D D- E 100-94 93-89 88-85 84-82...
6.12 LAB: Grade distribution In this lab, you will write a JavaScript program that generates a...
6.12 LAB: Grade distribution In this lab, you will write a JavaScript program that generates a bar graph of letter grades from a distributions of scores. Implement the parseScores function (1 point) Implement the parseScores function to take a space-separated string of scores as an argument and return an array of score strings. Each score is a number in the range [0, 100]. Ex: "45 78 98 83 86 99 90 59" → ["45","78","98","83","86","99","59"] Hint: JavaScript's string split() function can...
Teacher has given 5 exams which are all equally weighted to determine each student's final grade....
Teacher has given 5 exams which are all equally weighted to determine each student's final grade. The scores received so far by one student are: Exam 1 95 Exam 2 89 Exam 3 94 Exam 4 83 The above student's average is therefore a function for the grade received on the 5th exam. For the above average function, name the input and output variables. Complete the table below to numerically analyze this function. Exam 5 score Final Average 100 (95...
C++ needs to output all of the name of the students not just first Write a...
C++ needs to output all of the name of the students not just first Write a program which uses an array of string objects to hold the five students' full names (including spaces), an array of five characters to hold each student's letter grade, a multi-dimensional array of integers to hold each of the five student's four test scores, and an array of five doubles to hold each student's average test score. The program will use a function to allow...
In your biology class, your final grade is based on several things: a lab score, scores...
In your biology class, your final grade is based on several things: a lab score, scores on two major tests, and your score on the test. There are 100 points available for each score. However, the lab score is worth 20% of your total grade, each major test is worth 22.5%, and the test is worth 35%. Compute the weighted average for the following scores: 96 on the lab, 78 on the first major test, 66 on the second major...
Write a program that asks for five test scores. The program should calculate the average test...
Write a program that asks for five test scores. The program should calculate the average test score and display it. The number displayed should be formatted in fixed-point notation, with one decimal point of precision. Display: (1) your (1) interactive dialog with the console, (2) the five test scores entered, and (3) the computed average. the pseudo code is: you will need to include a library for the output formatting for specifying decimal point display: #include <iomanip> in std namespace...
5) Create a Java program using Scanner: Write a program where you will enter the grade...
5) Create a Java program using Scanner: Write a program where you will enter the grade score for 5 classes, then it will display total points and average and it will display the grade based on percentage. Steps: 1) Declare variable integer for English, Chemistry, Java Programming, Physics and Math 2) Declare variable total and percentage 3) Create Scanner object and prompt the user to enter grades for each class and input grades after each class 4) Calculate total of...
Need someone to fix my code: #include<iostream> using namespace std; struct student { double firstQuizz; double...
Need someone to fix my code: #include<iostream> using namespace std; struct student { double firstQuizz; double secondQuizz; double midTerm; double finalTerm; string name; }; int main() { int n; cout<<"enter the number of students"<<endl; cin>>n; struct student students[n]; int i; struct student istudent; for(i=0;i<n;i++) {    cout<<"Student name?"; cin >> istudent.name; cout<<"enter marks in first quizz , second quizz , mid term , final term of student "<<i+1<<endl; cin>>students[i].firstQuizz>>students[i].secondQuizz>>students[i].midTerm>>students[i].finalTerm; } for(i=0;i<n;i++) { double marks=0; double score=students[i].firstQuizz+students[i].secondQuizz+students[i].midTerm+students[i].finalTerm; marks=(students[i].firstQuizz*0.25)+(students[i].secondQuizz*0.25)+(students[i].midTerm*0.25)+(students[i].finalTerm*0.50); double totalArrgegateMarks =...
write a program that automates the process of generating the final student report for DC faculty...
write a program that automates the process of generating the final student report for DC faculty considering the following restrictions. Consider declaring three arrays for processing the student data: studID studName studGrade The student ID is a random number generated by the 5-digit system in the range of (10000 - 99999). Create a function to assign the student ID generated in an array of numbers. Consider the following to generate the random number: Add the libraries: #include <stdlib.h> #include <ctime>...
In this lab, you complete a partially prewritten C++ program that uses an array. The program...
In this lab, you complete a partially prewritten C++ program that uses an array. The program prompts the user to interactively enter eight batting averages, which the program stores in an array. The program should then find the minimum and maximum batting average stored in the array as well as the average of the eight batting averages. The data file provided for this lab includes the input statement and some variable declarations. Comments are included in the file to help...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT