Math is wrong

So our problem is:

Read in five scores and output the average; then, for each score, output the amount by which that score differs from the average.

For example

Enter a score: 65.8
Enter a score: 99
Enter a score: 87.5
Enter a score: 88
Enter a score: 100

The average is 88.06

65.8 is below average by 22.26
99 is above average by 10.94
87.5 is above average by 0.56
88 is above average by 0.06
100 is above average by 11.94

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//CSC150 Lab11
//Ian Heinze
//11/3/2015

#include <iostream>
using namespace std;

const int 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;
        }
        else if (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????
1
2
// 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;

And also for line 40.
Looks like a digit '1' has been typed instead of letter 'i'
test_scores [1]

test_scores [i]
Wow...can't believe i didn't see that. Thanks!
Topic archived. No new replies allowed.