Star Search A particular talent competition has five judges, each of whom awards
ID: 3916801 • Letter: S
Question
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 performer’s final score is determined by dropping the highest and lowest score received, then averaging the three remaining scores. Write a program that uses this method to calculate a contestant’s score. It should include the following functions: • void getJudgeData() should ask the user for a judge’s 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. • void calcScore() should calculate and display 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. The last two functions, described below, should be called by calcScore, which uses the returned information to determine which of the scores to drop. • int findLowest() should find and return the lowest of the five scores passed to it. • int findHighest() should find and return the highest of the five scores passed to it.
***USING ARRAYS
Explanation / Answer
// 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 performer’s final score is determined by dropping the highest and lowest score received,
// then averaging the three remaining scores.
// Write a program that uses this method to calculate a contestant’s score.
// It should include the following functions:
// 1.... void getJudgeData() should ask the user for a judge’s 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.
// 2.... void calcScore() should calculate and display 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.
// The last two functions, described below, should be called by calcScore,
// which uses the returned information to determine which of the scores to drop.
// 3....int findLowest() should find and return the lowest of the five scores passed to it.
// 4.... int findHighest() should find and return the highest of the five scores passed to it.
// ***USING ARRAYS
#include <iostream>
using namespace std;
void getJudgeData();
void calcScore();
int findLowest();
int findHighest();
void getJudgeData(int i, float &judge_score){
cout << "Enter Judges "<< i+1 << " data" <<endl;
cout << "please enter values between 0 and 10" <<endl;
cin >> judge_score;
}
float findLowest(float arr[], int size) {
int i = 0;
float min = arr[0];
for (i = 0; i < size; ++i) {
if(min > arr[i])
min = arr[i];
}
return min;
}
float findHighest(float arr[], int size) {
int i = 0;
float max = arr[0];
for (i = 0; i < size; ++i) {
if(max < arr[i])
max = arr[i];
}
return max;
}
void calcScore(float arr[], int size){
int i = 0;
float sum = 0;
for (i = 0; i < size; ++i) {
sum += arr[i];
}
float avg = (sum - findHighest(arr, size) - findLowest(arr, size)) / (size - 2);
cout << "The calculated score is " << avg << endl;
}
int main(){
int size = 5;
float score_array[size];
float judge_score;
for (int i=0; i<size; i++){
getJudgeData(i, judge_score);
score_array[i] = judge_score;
}
calcScore(score_array, size);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.