Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program: Functions : A particular talent competition has five judges

ID: 3811256 • Letter: W

Question

Write a C++ program:

Functions :

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 contestants score. It should include the following functions:

void getJudgeData() - should ask the user for a judge's score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of the ve judges.

float calcScore() - should calculate 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.

void ndLowestHightest() - should find the lowest and the hightest of the five scores. It should be called by calcScore() , which can be used to determine which of the two scores to be dropped.

- Input Validation: Do not accept judge scores lower than 0 or higher than 10.

Explanation / Answer

#include <iostream>

using namespace std;

void getJudgeData(float *score)
{
cout << "Enter judge's score: ";
cin >> *score;
if (*score < 0 || *score > 10)
{
cout << "Please enter a score between 0-10 ";
cout << "try again" <<endl;
getJudgeData(score);
}
}

void ndLowestHightest(float scores[], float *low, float *high)
{
*low = scores[0];
*high = scores[0];
for(int i = 0; i < 5; i++)
{
if (*low > scores[i])
{
*low = scores[i];
}
if (*high < scores[i])
{
*high = scores[i];
}
}
}

float calcScore(float scores[])
{
float low, high;
ndLowestHightest(scores,&low, &high);
float total = 0;
for(int i = 0; i < 5; i++)
{
total += scores[i];
}
total -= (low +high);
return total/3;
}

int main()
{
float scores[5];
for(int i = 0; i < 5; i++)
{
getJudgeData(&scores[i]);
}
cout << "Score is " << calcScore(scores) << endl;

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote