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

Programming assignment : A particular talents competition has 5 judges, each of

ID: 3624131 • Letter: P

Question

Programming assignment :
A particular talents competition has 5 judges, each of whom award 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:
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 5 judges.
void calcScore() should 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 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 5 scores passed to it.
• int findHighest()should find and return the highest of the 5 scores passed to it.
Input Validation: Do not accept judge scores lower than 0 or higher than 10.
You may use more functions, but you must use at least the four listed above. Here are the prototypes:
// Function prototypes
void getJudgeData(double &);
void calcScore(double, double, double, double, double);
double findLowest(double, double, double, double, double);
double findHighest(double, double, double, double, double);

Hints:
- Compile your work frequently to avoid too many errors at one time.
- Verify the parameter lists in the prototype, the call, and the header for each function.
- You can call a function from inside another function.


Program requirements and/or constraints:

• No global variables are allowed!
• program must work for any valid input and not just the values shown in the sample output.
• Don't use material beyond the current topic

Sample run: User input is to the right of the colon or parenthesis:
Enter score between 0 and 10: 8
Enter score between 0 and 10: 7.5
Enter score between 0 and 10: 10
Enter score between 0 and 10: 8
Enter score between 0 and 10: 5
This contestant's talent score is: 7.83
Do you want to enter another set of scores? (y/n)y
Enter score between 0 and 10: 8
Enter score between 0 and 10: 8
Enter score between 0 and 10: 1
Enter score between 0 and 10: 8
Enter score between 0 and 10: 10
This contestant's talent score is: 8.00
Do you want to enter another set of scores? (y/n)y
Enter score between 0 and 10: 8.5
Enter score between 0 and 10: 7.6
Enter score between 0 and 10: 5.5
Enter score between 0 and 10: 9.4
Enter score between 0 and 10: 6
This contestant's talent score is: 7.37
Do you want to enter another set of scores? (y/n)y
Enter score between 0 and 10: 8
Enter score between 0 and 10: 11
Score must be in the range 0 - 10. Please re-enter score: 10
Enter score between 0 and 10: 15
Score must be in the range 0 - 10. Please re-enter score: 15
Score must be in the range 0 - 10. Please re-enter score: 7
Enter score between 0 and 10: 8
Enter score between 0 and 10: 9
This contestant's talent score is: 8.33
Do you want to enter another set of scores? (y/n)n



Explanation / Answer

please rate - thanks

#include <iostream>
#include <iomanip>
using namespace std;
void getJudgeData(double&);
void calcScore(double,double,double,double,double);       
double findLowest(double,double,double,double,double);      
double findHighest(double,double,double,double,double);   
int main()
{double s1,s2,s3,s4,s5;
char yesno;
do
{
getJudgeData(s1);
getJudgeData(s2);
getJudgeData(s3);
getJudgeData(s4);
getJudgeData(s5);
calcScore(s1,s2,s3,s4,s5);
cout<<"Do you want to enter another set of scores? (y/n) ";
cin>>yesno;
}while(yesno=='y'||yesno=='Y');
return 0;
}
void getJudgeData(double &s)
{cout << "Enter score between 0 and 10:: ";
cin>>s;
   while(s<0||s>10)
      {cout<<"Score must be in the range 0 - 10. Please re-enter score: ";        
       cin>>s;
      }
}
void calcScore(double s1,double s2,double s3,double s4,double s5)
{
   double sum,l,h;
   l=findLowest(s1,s2,s3,s4,s5);
   h=findHighest(s1,s2,s3,s4,s5);
   sum=s1+s2+s3+s4+s5-l-h;
   cout<<"This contestant's talent score is: "<<setprecision(2)<<fixed<<sum/3.<<endl;
}
double findLowest(double s1,double s2,double s3,double s4,double s5)
{double low=s1;
   if(s2<low)
      low=s2;
   if(s3<low)
      low=s3;
   if(s4<low)
      low=s4;
   if(s5<low)
      low=s5;
   return low;
}
double findHighest(double s1,double s2,double s3,double s4,double s5)
{ double high=s1;
if(s2>high)
      high=s2;
   if(s3>high)
      high=s3;
   if(s4>high)
      high=s4;
   if(s5>high)
      high=s5;
   return high;
}