A particular talent competition has 5 judges, each of whom awards a score betwee
ID: 3706310 • Letter: A
Question
A particular talent competition has 5 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 3 remaining scores. Write a program that uses this method to calculate a contestant's score. It should include the following functions: a) A function that asks 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 5 judges. Do not accept judge scores lower than O or higher than 10. o b) A function to calculate and display the average of the 3 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 5 scores. The two functions, described below, should be called by this function, which uses the returned information, to determine which of the scores to drop c) A function to find and return the lowest of the 5 scores passed to it. d) A function to find and return the highest of the 5 scores passed to it. el A function to display the output. The main function is given below. Implement the functions you have developed and execute you're the program using the following data:Explanation / Answer
float inp_score()
{
float ≻ // variable to hold the judge's score
do
{
cout<<" Enter your score";
cin>>sc;
}while(sc>=0.0 && sc<=10.0);
return sc;
}
void calc(float marks[])
{
int highest=high(marks); //calling of function to find position of highest score
int lowest= low(marks); //calling of function to find position of lowest score
float score=0.0;
for(int i=0;i<5;i++)
{
if(i==highest || i==lowest)
continue; //so that we don't calculate them in average
score+= marks[i];
}
score/=3;
display(score);
}
int high(float marks[])
{
int pos;
float temp=marks[0];
for(int i=1;i<5;i++)
{
if(marks[i]>temp)
{
temp=marks[i];
pos=i;
}
}
return(pos);
}
int low(float marks[])
{
int pos;
float temp=marks[0];
for(int i=1;i<5;i++)
{
if(marks[i]<temp)
{
temp=marks[i];
pos=i;
}
}
return(pos);
}
void display(float score)
{
cout<<"The final score by the judges is:"<<score;
}
void main()
{
float marks[5]; //variable to hold the marks of judges
for(int i=0; i<5; i++)
{
cout<<" Judge no. "<<i+1<<" marks:";
marks[i]= inp_score();
}
calc(marks);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.