Test Scores in an Array

Hello everyone.
This is the project I am currently working on.

"Given a file containing student names and test scores, you will write a program that will read the input data and store the information in arrays. Using the stored test scores you will compute the average test score for each student and the average test score for the class. The final output will be a display of the students’ names, there average test score, and the letter grade based on a 90, 80, 70, 60 grading scheme (90% and above A, 80% to 99.9% B, etc.)"

I am still working on the code right now, but I was wondering if it was possible to let the user insert their own numbers and names (like a cout in an array) or if I would have to make the test score numbers and last names in the code and it just output the array (or if I'm just over thinking this). I hope you guys understand what I am talking about.
Thank you in advance!
It says "Given a file..." therefore you should input the student data from a file. The formatting seems to be up to you but the easiest way would probably be a file with the format of:

number of students(P)
Name1 number of scores(n) score1 score 2 score 3 .... score n
Name2 number of scores(n) score1 score 2 score 3 .... score n
.
.
.
NameP ...

The number of students and number of scores is optional but makes it much easier if you're just using a base array instead of a vector.

So don't hard code it and don't use cin(although cin will work for testing your other functions).

Okay, I will try to write it. I'll post it on here when I'm done. Thank you.
I found the file that my teacher wanted us to use. Here is the code so far, but it has errors. I don't understand how to fix these (they are commented on the lines they appear).

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
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>

using namespace std;

const int NUMROWS = 10;
const int NUMCOLUMNS = 7;


int numColumns;
int numRows;
int matrix [numRows][numColumns]; //error: Variable length array delcaration not allowed at file scope
void sumRows(int matrix[][numColumns],int numRows);

int main()
{
    const int MAX_ARRAY_SIZE = 10;
    string name[MAX_ARRAY_SIZE] = {"Johnson", "Aniston", "Cooper", "Gupta", "Blair", "Clark", "Kennedy", "Bronson", "Sunnyu", "Smith"};
    for (int i=0; i < MAX_ARRAY_SIZE; i++)
        int studentGrades[NUMROWS][NUMCOLUMNS] = {{85 83 77 91 76}, {80 90 95 93 48}, {78 81 11 90 73}, {92 83 30 69 87}, {23 45 96 38 59}, {60 85 45 39 67}, {77 31 52 74 83}, {93 94 89 77 97}, {79 85 28 93 82}, {85 72 49 75 63}}; //error: Expected "}"

   
    system("pause");
    return 0;
}

void sumRows(int matrix[][numColumns],int numRows);
{
    int row;
    int column;
    int sum;
    for(row = 0; row < numrows; row++)
    {
        sum = 0;
        for(column = 0; column < numColumns; column++)
            sum = sum + matrix[row][column];
            cout << "average = " << (row + 1) << sum << endl;
    }
}
Line 12 and 13 are uninitialized.
Line 14 - How many rows and columns is the compiler supposed to allocate given that lines 12 and 13 are uninitialized? BTW, it's not valid C++ to declare an array with non-const dimensions.

Did you mean this for line 14 instead?
 
int matrix [NUMROWS][NUMCOLUMNS]; 


Line 15,29 - same problem. numColumns is non-const.

Line 22 - What is this supposed to do? You initialize studentGrades 10 times, then studentgrades immediately goes out of scope. Why is this a loop? You never use i inside the loop.

For line 22, should I just take out line 21 all together? Would that make it correct? Sorry, I'm looking at my book and notes and trying to figure it all out.
For the lines 12 and 13, I put
1
2
int numColumns = 7;
int numRows = 10;

Is that correct?
Sorry, I'm new to programming.
Topic archived. No new replies allowed.