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.
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.
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.
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;