Formatting issue

I'm writing a program for a class that takes a source file and computes averages for all students and the produces the average for each test and then takes the highest and scores. I can do all the programming however I can't do the formatting. Right now my program looks like this when all said and done.

1
2
3
4
5
6
Students      1     2     3     4        Average
Adams    97    29   100    88           78.5
Brown    99    88    77    66            161
Carter    94    55    66    77            234
Davis     0    22    77    88         280.75
Wilson    77    55    88    55          349.5



I need it to look like this:

1
2
3
4
5
6
Students     1     2     3     4	 Averages	
Adams       97    29   100    88	   78.5
Brown       99    88    77    66	   82.5
Carter      94    55    66    77	   73.0
Davis        0    22    77    88	   46.8
Wilson      77    55    88    55	   68.8
Average     73.4  49.8  81.6  74.8  	
High score  99    88   100    88
Low score    0    22    77    55 



Here is my current code for the output:

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
cout << "                        Tests" << endl;
	
	cout << "Students " << setw(9);
	
	for (testList = 1; testList <= numTestScores; testList++)
		cout << setw(6) << testList << setw(6);
	
	cout << setw(15) << " Average" << endl;
	
	
	
	
	for (studList = 0; studList < numStudents; studList++)
	{
		cout << StudentArray[studList] << setw(20);
		
		for (testList = 0; testList < numTestScores; testList++)
		{
			cout << right << setw(6) << studentTest[studList][testList];
		}
		
		cout << setw(15) << Studaverage[studList] << endl;
	}
	
	return 0;
	
	}


Any help would be great and I thank you all in advance.
Now it looks like this:

1
2
3
4
5
6
Students      1     2     3     4        Average
Adams    97    29   100    88           78.5
Brown    99    88    77    66           82.5
Carter    94    55    66    77             73
Davis     0    22    77    88          46.75
Wilson    77    55    88    55          68.75
Average   73.4  49.8  81.6  74.8
High score     99    88   100    88
Low score      0    22    66    55


My code looks like this:
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
61
62
	// Print out the header for all the information
	
	cout << "                        Tests" << endl;
	
	cout << "Students " << setw(9);
	
	for (testList = 1; testList <= numTestScores; testList++)
		cout << setw(6) << testList << setw(6);
	
	cout << setw(15) << " Average" << endl;
	
	
	// Print out all the array information and the averages
	
	for (studList = 0; studList < numStudents; studList++)
	{
		cout << StudentArray[studList] << setw(20);
		
		for (testList = 0; testList < numTestScores; testList++)
		{
			cout << right << setw(6) << studentTest[studList][testList];
		}
		
		cout << setw(15) << Studaverage[studList] << endl;
	}
	
	// Print out the dashed line
	
	cout << "--------------------------------------"<< endl;
	
	// Print out the test average line
	
	cout << "Average " << setw(20);
	
	for (testList = 0; testList < numTestScores; testList++)
	{
		cout << setw(6) << TestAverage[testList];
	}
	
	cout << endl;
	
	// Print out the higest score line
	
	cout << "High score " << setw(20);
	
	for(testList =0; testList <numTestScores; testList++)
	{
		cout << setw(6) << Highest[testList];
	}
	
	cout << endl;
	
	// Print out the lowest score line
	
	cout << "Low score " << setw(20);
	
	for(testList= 0; testList < numTestScores; testList++)
	{
		cout << setw(6) << Lowest[testList];
	}
	
	cout << endl;


Once again I could really use the help in making it look like the example in the above post.
Topic archived. No new replies allowed.