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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
void getJudgeData(double& jscore, int& numjudge);
double calcScore(double& score, double& j1, double& j2, double& j3, double& j4, double& j5, double& highest, double& lowest);
double getHighest(double& highest, double& j1, double& j2, double& j3, double& j4, double& j5);
double getLowest(double& lowest, double& j1, double& j2, double& j3, double& j4, double& j5);
int main()
{
double jtotal, jscore, j1, j2, j3, j4, j5, score, highest, lowest;
int numjudge;
numjudge = 1;
getJudgeData(jscore, numjudge);
j1 = jscore;
numjudge = numjudge + 1;
getJudgeData(jscore, numjudge);
j2 = jscore;
numjudge = numjudge + 1;
getJudgeData(jscore, numjudge);
j3 = jscore;
numjudge = numjudge + 1;
getJudgeData(jscore, numjudge);
j4 = jscore;
numjudge = numjudge + 1;
getJudgeData(jscore, numjudge);
calcScore(score, j1, j2, j3, j4, j5, highest, lowest);
cout << score << endl;
return 0;
}
void getJudgeData(double& jscore, int& numjudge)
{
cout << "Input the score given by Judge " << numjudge << ".\n(score between 1-10)" << endl;
cin >> jscore;
}
double calcScore(double& score, double& j1, double& j2, double& j3, double& j4, double& j5, double& highest, double& lowest)
{
double total;
double findLowest(double, double, double, double, double);
double findHighest(double, double, double, double, double);
total = j1 + j2 + j3 + j4 + j5;
score = total - highest - lowest;
score = score / 3;
return score;
}
double findLowest(double lowest, double j1, double j2, double j3, double j4, double j5)
{
lowest = j1;
if (j2 < j1)
{
lowest = j2;
}
if (j3 < j1)
{
lowest = j3;
}
if (j4 < j1)
{
lowest = j4;
}
if (j5 < j1)
{
lowest = j5;
}
return lowest;
}
double findHighest(double highest, double j1, double j2, double j3, double j4, double j5)
{
highest = j1;
if (j2 > j1)
{
highest = j2;
}
if (j3 > j1)
{
highest = j3;
}
if (j4 > j1)
{
highest = j4;
}
if (j5 > j1)
{
highest = j5;
}
return highest;
}
|