Question

Lowest Score Drop In Functions, there can only be one return statement. You can not use...

Lowest Score Drop In Functions, there can only be one return statement. You can not use an exit or break function. Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getScore() should ask the user for a test score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the five scores to be entered. This function will call the isValid function. Sending it the value to test along with highest possible valid score (100). Use a local static variable for which score is to be entered. void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main and should be passed the five scores. Include 2 decimal places on the result. double findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop. bool isValid() should determine if the test score is a valid one. Do not accept test scores lower than 0 or higher than the highest score that is passed in. Test scores may have decimal places, such as 85.6. This function should be called by getScore. Do not use the min or max C++ functions.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot of program code:-

Screenshot of output:-

Program code to copy:-

#include <iostream>
#include <iomanip>

using namespace std;

//Function prototype
bool isValid(double score,int maxScore);
void getScore(double &score);
double findLowest(double score[]);
void calcAverage(double score[]);

//main() function
int main()
{
   double static score[5];
  
   for(int i=0; i<5; i++)
   {
       //Calling function to get the score
       getScore(score[i]);
   }
   //Calling function to calculate & print the average score
   calcAverage(score);
  
   return 0;
}

//Function to validate the score
bool isValid(double score,int maxScore)
{
   if(score>=0 && score<=100)
       return true;
   else
       return false;
}

//Function to get the score from user
void getScore(double &score)
{   
   do
   {
       //Prompt & read the score from user
       cout << "Enter the score: ";
       cin >> score;
       //Validating the score
       if(!isValid(score,100))
           cout << "Invaild input!Enter score between 0 to 100" << endl;      
   }while(score<0 | score>100);
}

//Function to find the lowest score
double findLowest(double score[])
{
   int lowest = score[0];
   for(int i=1; i<5; i++)
   {
       if(score[i]<lowest)
           lowest = score[i];
   }
   return lowest;
}

//Function to calculate the average score
void calcAverage(double score[])
{
   double sum;
  
   //Calculating sum of five scores
   for(int i=0; i<5; i++)
   {
       sum += score[i];
   }
   //Calling function to get lowest scrore
   double lowest = findLowest(score);
   //subtracting lowest score from sum of five score
   sum -= lowest;
   //Calculating average score
   double average = sum/4.0;
  
   //Printing average score on screen
   cout << setprecision(1) << fixed;
   cout << "Average Score = " << average << endl;
}

Add a comment
Know the answer?
Add Answer to:
Lowest Score Drop In Functions, there can only be one return statement. You can not use...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help with this c++ question please thank you ltls. The program should urt valte....

    I need help with this c++ question please thank you ltls. The program should urt valte. 11. Lowest Score Drop Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getscore() should ask the user for a test score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of...

  • Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that...

    Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions. • void getScore() should ask the user for a test score, store it in the reference parameter variable, and validate it. This function should be called by the main once for each of the five scores to be entered. •...

  • A particular talent composition has 5 judges, each of whom awards a score between 0 and...

    A particular talent composition has 5 judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 8.3, are allowed. A performer's final score is determined by dropping the lowest and the highest score received, then averaging the 3 remaining scores. Write a program that uses this method to calculate a contestant's score. It should include the following functions: double getJudgeData() should ask the user for a judge's score and validate the score....

  • ***C++ Code*** What this Assignment Is About: -Learn to define and call void & non-void functions...

    ***C++ Code*** What this Assignment Is About: -Learn to define and call void & non-void functions -Learn to use reference variables Coding Guidelines for All Labs/Assignments (You will be graded on this) -Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc). -Keep identifiers to a reasonably short length. -Use upper case for constants. Use title case (first letter is upper case) for classes. Use lower case with uppercase word separators for all other identifiers (variables,...

  • Write a program that dynamically allocates an array in the freestore large enough to hold a...

    Write a program that dynamically allocates an array in the freestore large enough to hold a user defined number of test scores as doubles. Once all the scores are entered, the array should be passed to a function that finds the highest score. Another function the array should be passed to a function that finds the lowest score. Another function should be called that calculates the average score. The program should show the highest, lowest and average scores. Must use...

  • Write a program that dynamically allocates an array in the freestore large enough to hold a...

    Write a program that dynamically allocates an array in the freestore large enough to hold a user defined number of test scores as doubles. Once all the scores are entered, the array should be passed to a function that finds the highest score. Another function the array should be passed to a function that finds the lowest score. Another function should be called that calculates the average score. The program should show the highest, lowest and average scores. Must use...

  • c plus plus determines which of 5 geographic regions within a major city north south east...

    c plus plus determines which of 5 geographic regions within a major city north south east west and central had the fewest reported traffic accidents last year it should have the following function which are called by main int get NumAccidents is passed the name of a region it asks the user for the number of traffic accidents reported in that region during the last year validates the input then returns it. it should be called once for each city...

  • Write a Python program that asks the user to type in their three quiz scores (scores...

    Write a Python program that asks the user to type in their three quiz scores (scores between 0 and 100) and displays two averages. The program should be written so one function gets the user to input a score, another function takes the three scores and returns the average of them. And another function takes the three scores and averages the two highest scores (in other words, drops the lowest). Each of these functions should do the computation and return...

  • Please Write in C++ (10-30) @ 11:55pm 1.9 HW7 This homework assignment gives you the opportunity...

    Please Write in C++ (10-30) @ 11:55pm 1.9 HW7 This homework assignment gives you the opportunity to practice functions, functions that call other functions, reference variables, logical statements (what is meant by logical statement is a statement such as if, if/else if, switch), and input validation, HW7 (Graded out of 100) A talent competition has 5 judges, each of whom awards a score between 0 and 10 for each performer. Fractional scores, such as 8.3, are allowed. A performer's final...

  • Help. Write a C++ program that determines which of a company's four divisions (North, South, East,...

    Help. Write a C++ program that determines which of a company's four divisions (North, South, East, West) has the greatest sales for the quarter. It should include three functions at a minimum: float getSales() is passed the name of a division. It asks the user for a division's quarterly sales figure, calls a validate() function that will validate the input, and then returns the value back to main(). This function should be called once for each division. void validate() is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT