I have to compute the olympic average(removing highest and lowest score and then taking the average of what's left) using a for loop and if statements. I can get the lowest value out, but I can't get the highest. Here's what I have so far:
// ,CMPSC , olympic average
#include <iostream>
#include <fstream>
using namespace std;
int main ()
{
ifstream leaderboard ("E:\\filename");
int howmany, i;
double number, lowest, highest,sum=0,score;
leaderboard >> howmany;
leaderboard >> number ;
sum = number;
for (i=2; i<= 10; i++)
{
leaderboard >> score;
sum += score;
if ( score < number)
{
score = lowest;
}
}
cout << "average score is: "<<(sum- (highest+lowest))/(howmany-2)<<endl;
return (0);
}