Calculating averages and alignment issues

Hello, so I'm working on a program and can't seem to get it to work properly

I need it to display this when run:

1
2
3
4
5
6
7
Name 1  2  3  4  5  6  7  8  9  10    Low Avg
A.A. 5  11 9  5  8  5  3              3   7.2
R.D. 11 2  3  12 8  11 9              2   9.0
J.E. 10                               N/A 10.0
K.H. 4  11 5  4  6  8  2  6  11 5     2   6.7
G.M. 10 1  1  9  3                    1   5.8
S.O. 3  1  6                          1   4.5


However it currently displays this:

1
2
3
4
5
6
7
8
9
Name     1    2    3    4    5    6    7    8    9    10   Low  Avg
A.A.     5    11   9    5    8    5    3    6.6
R.D.     11   2    3    12   8    11   9    7.3
J.E.     10   7.5
K.H.     4    11   5    4    6    8    2    6    11   5    7.0
G.M.     10   1    1    9    3    6.6
S.O.     3    1    6    6.3
All Student Processed.
Press any key to continue . . .


Other relevant details can be found in this prior post from when I was working on this same program before: http://www.cplusplus.com/forum/general/52521/

There are a couple things I can't figure out how to do.

1) Remove the lowest score before calculating the average and display that score under "Low"

2) Properly align all text.

Here is the current code:

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
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

int main()
{

	ifstream gradeFile;	
 	gradeFile.open("ScoreData.txt");

	if(gradeFile.fail())
	{	
		cout << "File not found. Program terminated." << endl;
		return 1;
	}
	
	char initial1;		// initial one
	char initial2;		// initial two
	int score;			// student's test scores
	int numscores = 0;
	int sum = 0;
	float average;
	int s = 1;
	int lowestscore = 0;
	int M = 20;

	cout << "Name     ";
	for(s; s <= 10; s++)
		cout << left << setw(5) << s;
		cout << left << setw(5) << "Low";
		cout << left << setw(5) << "Avg";
	
	while(!gradeFile.eof())
	{
		gradeFile >> initial1 >> initial2;
		cout << "\n" << initial1 << "." << initial2 << ".     ";
		
		do
		{
			gradeFile >> score;
			if(score != -1)
			{
			cout << left << setw(5) << score;
			sum += score;
			numscores++;
			}
		}
		while(score != -1);

		average = (float) (sum - lowestscore) / numscores;
		cout << left << setw(5) << fixed << setprecision(1) << average; 
	}
	
	//for(
	gradeFile.close();
	cout << "\nAll Student Processed." << endl;

	return 0;
}


Any help is appreciated, thanks!
Topic archived. No new replies allowed.