Getting started with array project

Hey guys, I'm extremely new to programming and always seem to need a little understanding to how to start my projects then I do well from there.

My teacher gave me a txt file with a bunch of values and my problem statement is:

You're given a file that contains a collection of IDs and scores for an exam in your computer course. You're to compute the adverage of these scores and assign grades to each student according to the following rule:

If a student's score is within 10 points (above or below) of the average, assign a grade of satisfactory. If a student's score is more than 10 points above average, assign a grade of outstanding. If a student's score is more than 10 points below average, assign a grade of unsatisfactory.
The output from your porgram should consist of a labeled three-column list that shows the ID, score, and corresponding grade. As part of the solution, your program should include functions that correspond to the function prototypes that follow.

// reads exam scores into array scores
void readStuData
(ifstream &rss,
int score[],
int id[],
int &count,
bool &tooMany);

// computes average of count student scores
float mean(int scores[], int count);

// displays a table showing each students ID, score and grade
// on a separate line
// uses: printGrade
void printTable(int score[], int ID[], int count);

// prints student grade after comparing oneScore to average
void printGrade(int ineScore, float average);
In fact you need not to use arrays because you can process input data line by line and then print read ID, calcukated average and score.
Last edited on
What about when I display each ID and score?
it would be easier to use arrays... Just saying.

it would be, howevere, extremely complex, as you would have to parse and extrapolate the pieces of data that you need for any purpose. Here is a program I'm writing that uses a 1gb array to store string data and a 1kb array that is uded to store the number of files. This is a program to back up my computer's data. I wrote it so that i could "add" fdirectories and files corresponding with those directories. Heres the array parsing part:

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
string get_backup_dat(string bkpname)
{
    string files[1000][1000];
    int sizes[1000];
    int d, dim = -1, dim2 = -1;
    string line, dir;
    bkpname = ("\\backups\\" + bkpname + "\\");
    d = check_dir(bkpname);
    if(d == 0)
    {
        cls();
        _cl();
        return "";
    }
    ifstream b;
    b.open(bkpname.c_str(), ios::in);
    while(b.good())
    {
        dim2 = -1;
        dim++;
        dim2++;
        getline(b, line);
        dir = line;
        files[dim][0] = dir;
        line.clear();
        while(dir != line)
        {
            dim2++;
            getline(b, line);
            if(line == dir)
            {
                break;
            }
            files[dim][dim2] = line;
        }
        sizes[dim] = dim2;
    }
    b.close();
    ofstream s;
    s.open("sizes.dat", ios::out);
    for(int x = 0; x <= dim; x++)
    {
        s<< sizes[x]<< " ";
    }
    s.close();
    return *files;
}


given the backup name/folder as an argument, the program has to read the file with the folder/file data.

Whether you use vectors, arrays, or nothing doesnt really matter though. It's really just whatever floats your boat. I chose this route because it would be the most organized way for my program to operate. The files corresponding to their folder/directories wouldn't be seperated and vice-versa.
IWishIKnew wrote:
it would be easier to use arrays... Just saying.
it would not be(streaming it without arrays is simpler). all you need is a variable for ID and one for score and when you are done manipulating the variables upload your new variables and continue.
Topic archived. No new replies allowed.