Student Score/Average Array

I have to make a program to find student's test scores and etc. I am stumbled on a few problems I can't seem to figure how to implement and create the following functions: (I managed to create a function to get average score of each student)

1. A void function to find the average score for each test and store in an array testAvgs. (average overall score of each test)

2. A void function to print the average score for each student and the average score for each test, i.e. print the contents of studentAvgs and testAvgs. The output will be well formatted and accompanied with appropriate titles for the information printed and for the rows and columns.

3. Add the following declaration in the function main.
"bool passing[MAX_STUDENTS];"

4. Then write a function that initializes all components of the array passing to false. The array passing is a parameter.
"void Initialize(bool passing[],int numberOfStudents)"

5. A function that has passing , studentAvgs, and numberOfStudents as parameters. Set the components of passing to true whenever the corresponding value in studentAvgs is greater than or equal to 50.0

6. A function that has passing as parameter and print the number of students who passed, i.e. count and print the number of components in passing that are true. Display meaningful messages with appropriate title.

7. A function that has studentAvgs and numberOfStudents as parameters, and determine the highest average score of the class. This value will be formatted and printed with an appropriate message.


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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
 #include <iostream> //for cin and cout
#include <iomanip> //better format
#include <conio.h> //for getch

using namespace std;

//constant declarations
const int MAX_STUDENTS = 30;	//maximum number of students
const int MAX_TESTS = 10;        //maximum number of tests

//function prototypes

void ReadScores(double[][MAX_TESTS],int& , int&);       

void PrintScores(const double[][MAX_TESTS], int, int);

void DisplayHeadings();

void AverageScores(const double scores[][MAX_TESTS], int, int, double studentAvgs[]);


int main()
{
     //variable declarations
     double scores[MAX_STUDENTS][MAX_TESTS];  //array of test scores
     int numberOfStudents;   //number of students in a class
     int numberOfTests;      //number of tests written
	 double studentAvgs[MAX_STUDENTS];	 //array for averages of each score


	 //Main Title/Heading
     DisplayHeadings();

     //read the each student’s test scores into an array scores  
     ReadScores(scores, numberOfStudents, numberOfTests); 

     //print each student’s scores
     PrintScores(scores,numberOfStudents,numberOfTests);

	 //Print average score of each student
	 AverageScores(scores, numberOfStudents, numberOfTests, studentAvgs);

	 //End of Program
     cout <<  "End of Program*" << endl;

     _getch();
}

//**************************************************************************
// Definition of function DisplayHeadings
// This function prints out a main title/header for the program
//**************************************************************************

void DisplayHeadings()
{
	cout << "Student Test Score Toolkit" << endl
		 << "--------------------------" << endl;
}

//***************************************************************************
// Definition of function ReadScores
// This function reads each student's test scores into array scores
// The parameter scores is an array to hold numbers between 0 and 100
//  entered as test scores.
// The parameter numberOfStudents is a reference parameter to the number of 
//  students read.
// The parameter numberOfTests is a reference parameter to the number of 
//  tests read.
//***************************************************************************

void ReadScores(double scores[][MAX_TESTS],  //array of test scores
                int& numberOfStudents,    //number of students read
                int& numberOfTests)       //number of tests read
{
     int student;  //row index used for students
     int test;     //column index used for tests

     //prompt for and read the number of students and the number of tests
     cout << "Enter the number of students(up to " << MAX_STUDENTS << "): ";
     cin >> numberOfStudents;

     cout <<"Enter the number of tests(up to " << MAX_TESTS << "): ";
     cin >> numberOfTests;
     
     //read the test scores into the array scores
     for (student = 0; student < numberOfStudents; student++)
     {
     		cout <<"Enter the " << numberOfTests 
                  << " test scores for student# " << (student + 1) << endl;

             for (test = 0; test < numberOfTests; test++)
            	    cin >> scores[student][test];
     }
}

//**************************************************************************
// Definition of function PrintScores
// This function prints each student's test scores
// The parameter scores is an array to hold each student’s test scores
// The parameter numberOfStudents holds the number of students integers 
// The parameter numberOfTests holds the number of tests.
//**************************************************************************

void PrintScores( const double scores[][MAX_TESTS],
					int numberOfStudents,
                    int numberOfTests)
{
     int student;
     int test;

     for (student = 0; student < numberOfStudents; student++)
     {
     		cout <<"The test scores for student# " << (student + 1)
                  <<" are: " << endl;

         for (test = 0; test < numberOfTests; test++)
            	cout << setw(3) << scores[student][test];

         cout << endl;
     }
}

//**************************************************************************
// Definition of function AverageScores
// This function prints the average score for each student
// The parameter scores is an array to hold each student’s test scores and
//	max number of tests.
// The parameter numberOfStudents holds the number of students integers 
// The parameter numberOfTests holds the number of tests.
// The parameter studentAvgs holds the average test score of each students
//**************************************************************************

void AverageScores( const double scores[][MAX_TESTS], int numberOfStudents, 
					int numberOfTests, 
					double studentAvgs[])
{
	double total = 0;
	for (int student=0;student<numberOfStudents;student++)
	{
		total = 0;
		{
			for (int test=0; test<numberOfTests;test++)
				total = total + scores[student][test];
		}
		studentAvgs[student] = static_cast<double>(total)/numberOfTests;
		cout << endl;
		cout <<"The Average score for student " << student+1 << " is " << studentAvgs[student] << endl;
	}
}


Thank You
Last edited on
Any help would be appreciated
Topic archived. No new replies allowed.