This program is to calculate the average, high and low score of a series of use inputs. The output I am getting is high, low, average, high, low. I have no idea why or how this can happen. Side note, I am aware the coding isn't very good but the program otherwise works.
int main () // calculates test scores, printing high, low, and average.
{
double scores[75];
int counter = -1;
do
{
counter++;
cout << "Please enter a score (enter -1 to stop): ";
cin >> scores[counter];
} while (scores[counter] >= 0);
double total = 0.0;
for (int y = 0; y < counter; y++)
{
if (y >= 0)
total += scores[y];
else
{
}
}
double high = 0.0, low = 75.0;
for (int x = 0; x < counter; x++)
{
double score = scores[x];
if (x < 0)
{
}
if ((score >= 0)&&(score > high))
high = score;
if ((score >= 0)&&(score < low))
low = score;
else
cout << "Average is " << (total / (double) (counter)) << endl;
cout << "Highest is " << high << endl;
cout << "Lowest is " << low << endl;
}
}