Hey compiling problems.

So I am working with arrays for the first time and I am extremely confused. I'm getting a ton of compiling errors. Any help? Thanks

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cmath>

using namespace std;

void readStuData
(ifstream grades,
int score [],
int id[]
int &count,
bool &tooMany);

int main()
{
ifstream myfile ("Grades.txt"); // Input from external file
int id[0]; // the ID of students
float mean(int score[1, 2, 3, 4, 5, 6, 7], int count); // average of individuals scores
string grade;
int &count;
int &tooMany;





if (myfile.is_open())
{
while ( myfile.good() )
{

if (mean > mean + 10)
{
grade = "outstanding";
}
else if (mean < mean - 10)
{
grade = "unsatisfactory";
}
else
{
grade = "satisfactory";
}

mean = (score++ / count);

void printTable(int score[1, 2, 3, 4, 5, 6, 7], int id[0], int count);
myfile >> id >> score >> endl;
cout << id << " " << mean << " " << grade << " " << endl;




}
myfile.close();
}

else cout << "Unable to open file";

return 0;


}




Heres the problem statement

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.

we were also given this file (grades.txt)

3313 90 42 58 64 70 75 100
5688 88 48 79 70 79 70 94
4700 50 44 89 73 70 73 100
9561 88 69 88 87 84 63 98
3199 96 69 100 90 88 67 100
3768 78 57 80 59 57 15 60
8291 72 56 70 82 74 9 83
7754 76 62 93 100 78 41 58
8146 94 68 99 94 93 9 54
2106 98 47 96 94 70 27 100

1
2
3
4
5
6
void readStuData
(ifstream grades,
int score [],
int id[]
int &count,
bool &tooMany);
This is missing a comma.

float mean(int score[1, 2, 3, 4, 5, 6, 7], int count); This is just incomprehensible. What is this meant to be? What are all those numbers doing in there?

1
2
int &count;
int &tooMany;
This indicates that you don't know what a reference is. I think you meant:
1
2
int count;
int tooMany;



if (mean > mean + 10)
Here, mean is an array, which devolves in this use to a pointer. So you're comparing a pointer, with a pointer plus 10. It makes no sense.


mean = (score++ / count); score does not exist.

And on and on...
Last edited on
Okay I made a few adjustments however, I don't know how to indicate the id which is line 0 on the grades.txt doc. and I don't know how to indicate the scores which is 1 to 6 on the grades doc. Also, the mean < mean + 10 and so on. I dont know how to calculate the mean of the scores and then provide a corresponding grade of "satisfactory, unsatisfactory, or outstanding" based off the 10 points above, within and below the average scores.




// File: stugrades.cpp
// Computes a external file and compiles it into a table with 3 columns of ID numbers, scores, and corresponding scores.

#include <iostream>
#include <fstream>
#include <cstdlib>
#include <cmath>

using namespace std;

void readStuData
(ifstream grades,
float score[],
int id[],
int count,
bool tooMany);

int main()
{
ifstream myfile ("Grades.txt"); // Input from external file
int id[0]; // the ID of students
float score[1, 2, 3, 4, 5, 6];
float mean; // average of individuals scores
string grade;
int count;
int tooMany;





if (myfile.is_open())
{
while ( myfile.good() )
{

if (mean > mean + 10)
{
grade = "outstanding";
}
else if (mean < mean - 10)
{
grade = "unsatisfactory";
}
else
{
grade = "satisfactory";
}

mean = (score++ / count);

void printTable(int score[1, 2, 3, 4, 5, 6], int id[0], int count);
myfile >> id >> score >> endl;
cout << id << " " << mean << " " << grade << " " << endl;




}
myfile.close();
}

else cout << "Unable to open file";

return 0;


}
Topic archived. No new replies allowed.