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 validation ();
double findLowest(int, double &);
double findHighest(int, double &);
double Average(int, double);
int i = 0, n = 5;
int main(){
double min, max, total = 0, avg;
min = findLowest(n, total);
max = findHighest(n, total);
avg = Average(n, total);
cout << fixed << setprecision(1);
cout << "Lowest Score: "<<min<<endl;
cout << "Highest Score: "<<max<<endl;
cout << "Final Score: "<<avg<<endl;
system("pause");
return 0;
}
double validation(){
double x;
for(int score = 1; score = 5; score++){
cout << "Score "<< i+1<<": ";
cin >> x;
i++;
while(x>=0 || x<=10)
cout<<"Invalid Score. Try again.";
return x;
}
}
double findLowest(int n, double &total)
{
double min, g;
for (int j = 1; j <=5; j++)
{
g = validation();
total += g;
if (j == 1)
min = g;
else if (g < min)
min = g;
}
total -= min;
return min;
}
double findHighest(int n, double &total)
{
double max, g;
for (int j = 1; j <=5; j++)
{
g = validation();
total += g;
if (j == 1)
max = g;
else if (g > max)
max = g;
}
total += max;
return max;
}
double Average(int n, double total)
{
double avg;
avg = total / 3;
return avg;
}
|