hobbyenthusiast

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 ()

{
int howmany, i;
double number, lowest, highest,sum=0,score;

sum = number;

for (i=2; i<= 10; i++)
{
sum += score;

if ( score < number)
{
score = lowest;
}

}

cout << "average score is: "<<(sum- (highest+lowest))/(howmany-2)<<endl;

return (0);
}``````

rubberman 1,355

Think out the algorithm first. You want to remove the lowest and highest values, so first read all values into an array, determining the high/low values as you go and adding up the number of items read. When you are done, iterate through the array, adding up all but the high/low numbers and divide the resulting value by the number read (-2) to get your olympic average. From what I can see, you aren't doing that...

WaltP 2,905

Where do you deal with the highest value? I only see lowest.