1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
#include <iostream>
using namespace std;
void getJudgeData(float &);
void calcScore(float, float, float, float, float, float, float);
float findLowest (float, float, float, float, float);
float findHighest(float, float, float, float, float);
int main (int argc, char * const argv[]) {
float data1,data2,data3,data4,data5,lowest,highest;
getJudgeData(data1);
getJudgeData(data2);
getJudgeData(data3);
getJudgeData(data4);
getJudgeData(data5);
lowest=findLowest(data1, data2, data3, data4, data5);
highest=findHighest(data1, data2, data3, data4, data5);
calcScore(data1, data2, data3, data4, data5, highest, lowest);
return 0;
}
void getJudgeData(int &data){
cout << "enter score :\n";
cin>>data;
}
void caclScore(float score1, float score2, float score3, float score4, float score5,float highest,float lowest)
{
cout << "the average of the score excluding the highest and lowest is "<<((score1+score2+score3+score4+score5)-(highest+lowest))/3;
}
float findLowest(float score1, float score2, float score3, float score4, float score5)
{
if (score1<score2 && score1<score3 && score1<score4 && score1<score5)
{
return score1;
}
else if(score2<score1 && score2<score3 && score2<score4 && score2<score5)
{
return score2;
}
else if (score3<score1 && score3<score2 && score3<score4 && score3<score5)
{
return score3;
}
else if (score4<score1 && score4<score2 && score4<score3 && score4<score5)
{
return score4;
}
else if (score5<score1 && score5<score2 && score5<score3 && score5<score4)
{
return score5;
}
}//compler give me error here "control reaches end of non-void function"
float findHighest(float score1,float score2,float score3,float score4,float score5)
{
if (score1>score2 && score1>score3 && score1>score4 && score1>score5 )
{
return score1;
}
else if(score2>score1 && score2>score3 && score2>score4 && score2>score5)
{
return score2;
}
else if (score3>score1 && score3>score2 && score3>score4 && score3>score5)
{
return score3;
}
else if (score4>score1 && score4>score2 && score4>score3 && score4>score5)
{
return score4;
}
else if (score5>score1 && score5>score2 && score5>score3 && score5>score4)
{
return score5;
}
}//compler give me error here "control reaches end of non-void function"
|