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 105 106 107 108 109 110 111
|
#include <iostream>
#include <iomanip>
using namespace std;
double getScore( double maxScore );
bool isValid( double theScore, double maxValue );
double getSmallest(double theArray [], int theSize);
void displayArray(int theArray[], int theSize);
int sumArray(const int theArray[], int theSize);
int averageArray(const int theArray[], int theSize);
int findLargest(const int theArray[], int theSize);
int findSmallest(const int theArray[], int theSize);
void scoreArray(int theArray[], int theSize);
int main()
{
const double MAX_SCORE = 10;
cout << "Please enter the 5 judge scores" << endl;
const double s1 = getScore(MAX_SCORE);
const double s2 = getScore(MAX_SCORE);
const double s3 = getScore(MAX_SCORE);
const double s4 = getScore(MAX_SCORE);
const double s5 = getScore(MAX_SCORE);
const int SIZE = 5;
int tests[SIZE] = { 0 };
displayArray(tests, SIZE);
return 0;
}
//Array Stuff
int averageArray(const int theArray[], int theSize) {
return sumArray(theArray, theSize) / theSize;
}
int sumArray(const int theArray[], int theSize) {
int sum = 0;
for (int i = 0; i < theSize; i++) {
sum += theArray[1];
}
return sum;
}
void displayArray(int theArray[], int theSize) {
for (int i = 0; i < theSize; i++) {
if (i % 10 == 0) {
cout << endl;
}
cout << setw(7) << theArray[i];
}
cout << endl;
cout << endl;
}
void scoreArray(int theArray[], int theSize) {
for (int i = 0; i < theSize; i++) {
theArray[i] = s1, s2, s3, s4, s5;
}
}
int findLargest(const int theArray[], int theSize) {
int result = theArray[0];
for (int i = 1; i < theSize; i++) {
if (theArray[i] > result) {
result = theArray[i];
}
}
return result;
}
int findSmallest(const int theArray[], int theSize) {
int result = theArray[0];
for (int i = 1; i < theSize; i++) {
if (theArray[i] < result) {
result = theArray[i];
}
}
return result;
}
//Old Stuff
double getScore( double maxScore )
{
double score ;
cout << "Enter the judge scores: ";
cin >> score ;
if( isValid( score, maxScore ) ) return score ;
cout << "Invalid score, please enter a new one.";
return getScore(maxScore) ;
}
bool isValid( double theScore, double maxValue )
{ return theScore >= 0 && theScore <= maxValue ;}
| |