Code:
#include <iostream>
#include <iomanip>
int score1;
int s1, s2, s3, s4, s5, upperBound, lowerBound, avg, lowest, num, lowestScore, average, i;
char answer;
int getValue (int, int, int);
double calcAverage (int, int, int, int, int, int);
int findLowest (int, int, int, int, int);
using namespace std;
int main ()
{
do
{
cout << "What is the highest score?" << endl;
cin >> upperBound;
cout << "What is the lowest score?" << endl;
cin >> lowerBound;
for (i=1; i<=1; i++)
{
cout << "Enter a value in the range (" << lowerBound << "-" << upperBound << ")" << ":" << endl;
cin >> s1;
num = s1;
getValue (upperBound, lowerBound, num);
}
for (i=1; i<=1; i++)
{
cout << "Enter a value in the range (" << lowerBound << "-" << upperBound << ")" << ":" << endl;
cin >> s2;
num = s2;
getValue (upperBound, lowerBound, num);
}
for (i=1; i<=1; i++)
{
cout << "Enter a value in the range (" << lowerBound << "-" << upperBound << ")" << ":" << endl;
cin >> s3;
num = s3;
getValue (upperBound, lowerBound, num);
}
for (i=1; i<=1; i++)
{
cout << "Enter a value in the range (" << lowerBound << "-" << upperBound << ")" << ":" << endl;
cin >> s4;
num = s4;
getValue (upperBound, lowerBound, num);
}
for (i=1; i<=1; i++)
{
cout << "Enter a value in the range (" << lowerBound << "-" << upperBound << ")" << ":" << endl;
cin >> s5;
num = s5;
getValue (upperBound, lowerBound, num);
}
findLowest (s1, s2, s3, s4, s5);
lowestScore=findLowest (s1, s2, s3, s4, s5);;
calcAverage (s1, s2, s3, s4, s5, lowestScore);
average = calcAverage (s1, s2, s3, s4, s5, lowestScore);
cout << "Your average is: " << average << endl;
cout << "Do you wish to run this again? (y/n)" << endl;
cin >> answer;
}while (answer == 'y' or answer == 'Y');
}
int getValue( int lowerBound, int upperBound, int num )
{
if (num > lowerBound or num < upperBound)
{
cout << "This is not within our range, please enter another value" << endl;
}
}
int findLowest( int s1, int s2, int s3, int s4, int s5 )
{
int lowest;
if (s1 < s2 and s1 < s3 and s1 < s4 and s1 < s5)
{
lowest = s1;
return lowest;
}
else if (s2 < s1 and s2 < s3 and s2 < s4 and s2 < s5)
{
lowest = s2;
return lowest;
}
else if (s3 < s1 and s3 < s2 and s3 < s4 and s3 < s5)
{
lowest = s3;
return lowest;
}
else if (s4 < s1 and s4 < s3 and s4 < s2 and s4 < s5)
{
lowest = s4;
return lowest;
}
else if (s5 < s1 and s5 < s3 and s5 < s2 and s5 < s2)
{
lowest = s5;
return lowest;
}
}
double calcAverage( int s1, int s2, int s3, int s4, int s5, int lowest)
{
int avg;
avg = ((s1+s2+s3+s4+s5)-lowestScore)/4;
return avg;
}