Question
Introduction The program asks for input from the user, processes the information and displays its results back to the user using functions. Additional specifications have
Introduction
The program asks for input from the user, processes the information and displays its results back to the user using functions. Additional specifications have been added to the problem description from the book.
9. Star Search A particular talent competition has five judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 8.3, are allowed. A performers final score is determined by dropping the highest and lowest score received, then averaging the three remaining scores. Write a program that uses these rules to calculate and display a contestants score. It should include the following functions: void getJudgeData() should ask the user for a judges score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the five judges. Make the following change to void getJudgeData( ). The function should take in 2 parameters, not 1, as specified above The first parameter should be a string that holds the values "Judge 1", "Judge 2".. and so on. The second parameter should be a double reference parameter. The getJudgeData function should ensure that: score is numeric score is >= 0 score is <= 10 double calcScore() getAverage() should calculate and return the average of the three scores that remain after dropping the highest and lowest scores the performer received. This function should be called just once by main and should be passed the five scores. Invoke the getLowest and getHighest function from this function in order to drop highest and lowest scores before calculating average. In int main, invoke the getHighest, getLowest and getAverage functions and print out the values returned by these functions. Average, highest and lowest values must be printed in the int main function. All scores must be printed out to 2 places after the decimal place |
Refer to the Programming Standards document and follow the rules stated there in order to complete the program
Make the following change to void getJudgeData( ).
The function should take in 2 parameters, not 1, as specified above
The first parameter should be a string that holds the values "Judge 1", "Judge 2".. and so on. Each call to the function should contain the judge number.
The second parameter is a numeric reference parameter.
The function should check for non-numeric data. Look at code shown here for examples that check non-numeric input
DO NOT USE ANY GLOBAL VARIABLES
Make sure that the main function is the first function in the program listing. All other functions
should be placed after the main function!
should have function prototypes coded before the main function! The function prototypes to be used as as follows. Do not change the function prototypes from the ones shown below. Your functions MUST match up with these prototypes!
void getJudgeData(string jname, double &score);
double getAverage(double score1, double score2, double score3, double score4, double score5);
double getLowest(double score1, double score2, double score3, double score4, double score5);
double getHighest(double score1, double score2, double score3, double score4, double score5);
Here is code illustrating the use of the getJudgeData functions:
int main()
{
double score1, score2, score3,score4, score5, average_sc, lowest_sc, highest_sc;
getJudgeData("Judge 1", score1);
getJudgeData("Judge 2", score2);
getJudgeData("Judge 3", score3);
getJudgeData("Judge 4", score4);
getJudgeData("Judge 5", score5);
.
.
... = getAverage(....);
... = getLowest(....);
... = getHighest(....);
cout <<....
return 0;
}
Sample output from my implementation of the assignment
Use input is shown in bold blue lettering highlighted in yellow:
Data entry for Judge 1. Score must be in the range 0 - 10: ghjdgf
Data entry for Judge 1. Score must be in the range 0 - 10.
Please re-enter score: 12
Data entry for Judge 1. Score must be in the range 0 - 10.
Please re-enter score: 8.776
Data entry for Judge 2. Score must be in the range 0 - 10: 4.987
Data entry for Judge 3. Score must be in the range 0 - 10: 9.784
Data entry for Judge 4. Score must be in the range 0 - 10: 5.667
Data entry for Judge 5. Score must be in the range 0 - 10: 5.094
Score 1 Score 2 Score 3 Score 4 Score 5
--------------------------------------------------
8.78 4.99 9.78 5.67 5.09
--------------------------------------------------
Average = 6.51
Lowest = 4.99
Highest = 9.78
Press any key to continue . . .
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started