//CSC150 Lab11
//Ian Heinze
//11/3/2015
#include <iostream>
usingnamespace std;
constint NUM_SCORES = 5;
int main()
{
int i=0;
double test_scores[NUM_SCORES];
double sum=0;
double average;
while (i < NUM_SCORES)
{
cout << "Please enter the score: ";
cin >> test_scores[i];
sum = sum + test_scores[i];
i++;
}
cout << endl;
average = sum / NUM_SCORES;
cout << "The average is " << average << endl << endl;
for (int i=0; i < NUM_SCORES; i++)
{
if (test_scores [i] > average)
{
cout << test_scores [i] << " is above average by " << test_scores [1] - average << endl;
}
elseif (test_scores [i] < average)
{
cout << test_scores [i] << " is below average by " << test_scores [1] - average << endl;
}
else
{
cout << test_scores [i] << " is equal to the average. " << endl << endl;
}
}
return 0;
}
Soooooo, everything in my code now works, except for the math at the end where it tells how far each score is off from the average. Unless the score is equal to the average, it just gives the same answer for everything. Help please????
// cout << test_scores [i] << " is above average by " << test_scores [1] - average << endl; // line 36
cout << test_scores [i] << " is above average by " << test_scores [ /*1*/ i ] - average << endl;