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
|
#include <iostream>
#include <iomanip>
using namespace std;
double getScore(double &score, int, double);
double calcAverage(double, double, double);
double findLowest(double scoreArray[5]);
double findHighest(double scoreArray[5]);
int main()
{
double score, lowest = 0, highest = 0, scoreArray[5];
double total= 0;
int i = 0;
getScore(score, i, total);
getScore(score, i, total);
getScore(score, i, total);
getScore(score, i, total);
getScore(score, i, total);
cout << "Your score is: " << calcAverage(scoreArray[5], lowest, highest) << endl;
return 0;
}
double getScore( double &score , int i, double total)
{
double scoreArray[5];
for (int i = 0; i < 5; ++i)
{
cout << "Please enter a judge score: " << endl;
cin >> scoreArray[i];
total += scoreArray[i];
return score;
}
if (score < 0 || score > 10)
{
cout << "Please enter a valid judge score that is between 0 to 10\n";
cin >> score;
}
}
double calcAverage(double, double, double)
{
return 0.0;
}
double findHighest(double scoreArray[5]) {
int count;
double highest ;
highest = scoreArray[0];
for (count = 1; count < 5; count++)
{
if (scoreArray[count] > highest)
highest = scoreArray[count];
}
return highest;
}
double findLowest(double scoreArray[5]) {
int count;
double lowest ;
lowest = scoreArray[0];
for (count = 1; count < 5; count++)
{
if (scoreArray[count] > lowest)
lowest = scoreArray[count];
}
return lowest;
}
double calcAverage(double scoreArray[5], double lowest, double highest) {
double avg, sum = 0;
int total;
for (total = 0; total < 5; total++)
sum += scoreArray[5];
avg = ((sum - highest) + (sum -lowest)) / 3.0;
cout << "Your score is " << avg << endl;
return avg;
}
|