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
|
#include "stdafx.h"
#include <iostream>
using namespace std;
void getScore(int & test);
void calcAverage(int test1, int test2, int test3, int test4, int test5);
int findLowest(int test1, int test2, int test3, int test4, int test5, int lowest);
int main()
{
int test1, test2, test3, test4, test5, lowest;
getScore(test1);
getScore(test2);
getScore(test3);
getScore(test4);
getScore(test5);
lowest = findLowest(test1, test2, test3, test4, test5);
calcAverage(test1, test2, test3, test4, test5, lowest);
return 0;
}
void getScore(int &score)
{
cout << "Please enter the score: ";
cin >> score;
while (score < 1 || score >100)
{
cout << "Please enter a score between 0-100:";
cin >> score;
}
}
int findLowest(int test1, int test2, int test3, int test4, int test5)
{
int lowest = test1;
{
if (test2 < lowest)
lowest = test2;
else if (test3 < lowest)
lowest = test3;
else if (test4 < lowest)
lowest = test4;
else if (test5 < lowest)
lowest = test5;
}
return lowest;
}
void calcAverage(int test1, int test2, int test3, int test4, int test5,int lowest)
{
double average;
average = test1 + test2 + test3 + test4 + test5 - lowest / 4;
cout << "The average is: " << average << endl;
}
|