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
|
#include <iostream>
#include <iomanip>
using namespace std;
void getScore(int, int, int, int, int, int);
void calcAverage(int, int, int, int, int, int, int);
int findLowest(int, int, int, int, int, int);
int main()
{
static int average, test1, test2, test3, test4, test5, test6;
getScore (test1, test2, test3, test4, test5, test6);
calcAverage (average, test1, test2, test3, test4, test5, test6);
}
void getScore (int test1, int test2, int test3, int test4, int test5, int test6)
{
if (test1, test2, test3, test4, test5, test6 < 0 && test1, test2, test3, test4, test5, test6 > 100)
cout << "Invaild test score. Please enter a score between 0 and 100.";
cout << "Enter first score: ";
cin >> test1;
cout << "Enter second score: ";
cin >> test2;
cout << "Enter third score: ";
cin >> test3;
cout << "Enter fourth score: ";
cin >> test4;
cout << "Enter fifth score: ";
cin >> test5;
cout << "Enter sixth score: ";
cin >> test6;
}
void calcAverage( int average, int test1, int test2, int test3, int test4, int test5, int test6)
{
int small = findLowest(test1, test2, test3, test4, test5, test6);
average = (((test1 + test2 + test3 + test4 + test5 + test6) - small) / 5);
cout << small << endl;
cout << average;
system("pause");
}
int findLowest (int test1, int test2, int test3, int test4, int test5, int test6)
{
int small = test1;
if(small > test2)
{
small = test2;
}
if(small > test3)
{
small = test3;
}
if(small > test4)
{
small = test4;
}
if(small > test5)
{
small = test5;
}
if(small > test6)
{
small = test6;
}
return small;
}
|