Question: Write a program named Lab5c.cpp according to the following story. A particular talent competition has seven judges, each of whom awards a score between 0
Write a program named Lab5c.cpp according to the following story.
A particular talent competition has seven 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 highest and lowest score received, then averaging the remaining scores.
Write a program that uses the method described above to calculate a contestant's score. It should include the following functions:
void getJudgeData(double &score);
The function getJudgeData should use the random number generator to determine the judge's score and return the score through the reference parameter. This function should be called by the main function once for each judge.
double calcScore(double judgeScores[ ], int count);
The function calcScore should calculate and return the average of the scores that remain after dropping the highest and lowest scores the performer received. Call findHighest and findLowest to determine the highest and lowest scores. This function should be called just once by the main, and should be passed the seven scores.
double findLowest(double judgeScores[ ], int count);
The function findLowest should find and return the lowest of the scores passed to it.
double findHighest(double judgeScores[ ], int count);
The function should find and return the highest of the scores passed to it.
Check. The function prototypes are written above the main function.
Check. A comment box is provided above each function header and includes the following information: name, description, parameters, and return.
In the main function,
Collect Judge Data For Contestant
Define a named constant for the number of judges. For example, const int NUM_JUDGES = 7;
Define an array of doubles named judgeScores to hold seven judge scores for a contestant.
Use a for loop to call the function getJudgeData seven times to get scores from the seven judges and store the judge data in the array.
Check. Whenever the number of judges is needed in the code, use the named constant.
Calculate Contestant Score
Define a double variable named contestantScore.
Call the function calcScore to calculate the contestant's score and save that in the variable.
Report Contestant Score
On the score board, display the scores from the seven judges and the final score for the contestant. It should look as follows.
Scoreboard Scores from the judges:
Judge 1 10.0
Judge 2 9.8
Judge 3 9.8
Judge 4 9.2
Judge 5 9.9
Judge 6 9.0
Judge 7 8.7
Final score:
9.5
Check. The report is identical as shown above.
Important note: do not prompt the user. The function getJudgeData( ) should use the random number generator to determine the judge's score. 2 points will be deducted if you don't follow this instruction.
You can use the random number generator to generate a whole number in a certain range. With a slight modification, you can easily generate a fractional number within a range.
Note. The functions, findLowest() and findHighest() should return double instead of int.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
