Question: C++ PROGRAMMING C++ So I wrote this program that calculates the average for five test scores, and the lowest score is dropped. I can't get

C++ PROGRAMMING

C++

So I wrote this program that calculates the average for five test scores, and the lowest score is dropped. I can't get it to work. Can someone please revise it. DO NOT WRITE A COMPLETELY DIFFERENT PROGRAM... JUST FIX MY MISTAKES. Thank you! Run it on an IDE and you'll see where I made a mistake, it won't let me input any score, and I can't drop the lowest score.

#include #include

using namespace std;

//function prototypes double getScore(); //score has to be 0 - 100 double findLowest(double, double, double, double, double); double calcAverage(double, double, double, double, double); void display(double);

int main(int argc, char *argv[]) { //variable declaration double s1, s2, s3, s4, s5, avg; //call getScore 5 times s1 = getScore(); s2 = getScore(); s3 = getScore(); s4 = getScore(); s5 = getScore(); //call the calcAverage function avg = calcAverage(s1, s2, s3, s4, s5); //call display function display(avg); system("PAUSE"); return EXIT_SUCCESS; }

/* getScore function: this function displays a prompt and get a score from the keyboard input validation is needed to make sure the score is 0-100. The function returns the score */

double getScore() { double score; //declare a bool variable that controls a loop until a valid input is entered bool isValid=false; do { //prompt and read a score cout<<" Enter a score: "; cin>>score; //check is score is valid if(score>=0 && score<=100) isValid=true; //if valid exit the loop else //else print error message cout<<" Score entered is invalid. Score must be between 0-100 "; }while(!isValid); //return the score read return score; }

/* findLowest: this function returns the lowest score among the five scores */ double findLowest(double a, double b, double c, double d, double f) { double lowest; //check is a is the lowest score if(a/* calcAverage: this function calculates and returns the average after dropping the lowest */ double calcAverage(double a, double b, double c, double d, double f) { //call the findLowest function to get the lowest double lowest=findLowest(a,b,c,d,f); //get the total double total= a+b+c+d+f; //drop the lowest total=total-lowest;

//calculate the average double avg=total/4;

//return the average return avg; }

/* display: this function displays the average score */ void display(double a) { //display the avrage cout<<" The average score is: "<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!