Question
Note! This is a fairly complex program with detailed specifications. Please turn this program early for my comments! Introduction The program asks for input from
Note!
This is a fairly complex program with detailed specifications. Please turn this program early for my comments!
Introduction
The program asks for input from the user, processes the information and displays its results back to the user using functions.
9. Star Search A particular talent competition has five judges, each of whom awards a score between 0 and 10 (both 0 and 10 are considered valid!) 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 follow specifications shown above. 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.
Do not use the max and min functions that are part of Visual Studio!
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 findLowest(double score1, double score2, double score3, double score4, double score);
double findHighest(double score1, double score2, double score3, double score4, double score5);
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!
DO NOT USE ANY GLOBAL VARIABLES
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(....);
... = findLowest(....);
... = findHighest(....);
cout <<....
return 0;
}
double getAverage(double score1, double score2, double score3, double score4, double score5)
{
= .... - findHighest(.....) - findLowest(.....)
}
Take a look at this link to refresh your knowledge of creating data validation loops the check for numericity and values within a numeric range. The link takes you to Lab 2 from week 5.
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: kjhsdf
Invalid. Input must be numeric. Please re-enter score.
Data entry for Judge 1. Score must be in the range 0 - 10. ljaf
Invalid. Input must be numeric. Please re-enter score.
Data entry for Judge 1. Score must be in the range 0 - 10. -1
Invalid. Input must be 0-10. Please re-enter score.
Data entry for Judge 1. Score must be in the range 0 - 10. 22
Invalid. Input must be 0-10. Please re-enter score.
Data entry for Judge 1. Score must be in the range 0 - 10. 12
Invalid. Input must be 0-10. Please re-enter score.
Data entry for Judge 1. Score must be in the range 0 - 10: 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
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