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.
• 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.
• double calcScore() should calculate and return 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.#include<iostream>using namespace std;
void getJudgeData(double&);
double calcScore(double,double,double,double,double);
int findLowest(double,double,double,double,double);
int findHighest(double,double,double,double,double);
int main ()
{
double a,b,c,d,e,f;
getJudgeData(a);
getJudgeData(b);
getJudgeData(c);
getJudgeData(d);
getJudgeData(e);
f=calcScore(a,b,c,d,e);
cout<<"final score="<<f<<endl;
system("pause");
return 0;
}
void getJudgeData(double&s)
{
double a;
cout<<"Enter Score= ";
cin>>a;
if(a>=0 &&a<=10)
{
s=a;
}
else
{
cout<<"invalid Score"<<endl;
}
}
double calcScore(doublet,double u,doublev,double w,doublex)
{
double small,larg,avg,sum;
sum=t+u+v+w+x;
small=findLowest(t,u,v,w,x);
cout<<"Lowest Score= "<<small<<endl;
larg=findHighest(t,u,v,w,x);
cout<<"Largest Score= "<<larg<<endl;
sum=sum-larg-small;
avg=sum/3;
return avg;
}
int findLowest(double t,double u,double v,double w,double x)
{
double a;
if(t<u) a=t;
else a=u;
if (v<a) a=v;
if(w<a) a=w;
if(x<a) a=x;
return a;
}
int findHighest(double t,double u,double v,double w,double x)
{
double a;
if(t>u) a=t;
else a=u;
if (v>a) a=v;
if(w>a) a=w;
if(x>a) a=x;
return a;
}
For Any Problem Contact us on my mail apnapunjab7432@gmail.com