Need some help on a project

• 10-30-2011
Alvaro Ryfkogel
Need some help on a project
Code:

#include <iostream>
#include <iomanip>
#include<fstream>
using namespace std;
int main()
{
int grade, kount, average, max_score, min_score;
kount = 0;
ifstream inFile;

while (!inFile.eof()) {
kount += 1;

cout << "\n" << setw(10) << grade;

cout << "    Invalid \n";

cout << "    Unsatisfactory \n";

cout << "    Satisfactory \n";

cout << "    Outstanding \n\n";

else
cout << endl;
}

inFile.close();
cout << "\n\n\n Hit enter to continue...";
cin.get();

return 0;
}

Write a program to read in a collection of exam scores ranging in value from 0 to 100. Your program should count and print the number of outstanding scores (90 - 100), the number of satisfactory scores (60 - 89), the number of unsatisfactory scores (0 - 59) and the number of invalid scores (less than 0 or greater than 100).
It should display the average score (with 2 decimal digits), the highest score, the lowest score, and the category of every score. Do not include the invalid scores in the average, max, or min. You will need to create a data file named grades.txt.
Can I get some help with this? Not exactly the whole answer (if you gave me that I wouldn't be mad though) but just something to put me in the right path.
• 10-31-2011
Elysia
>>while (!inFile.eof())
You do not want to use eof as loop control (there is a FAQ on the site as to why).
Other than that, is there a specific problem you have in mind? You seem to have a basic skeleton, but not much more than that. Are you confused as how to approach these problems?
At the moment, I can give you a push in the right direction: think about how you would do it in real life, and then write down the logical steps in the logical order on a piece of paper.
If there are specific problems, feel free to ask.
• 10-31-2011
Rodaxoleaux
I thought fstream's eof() worked a different way than feof() in C since I never got the same problem as described in the FAQ. Never read anything about it; just thought.

@OP:

After using the if check for grade being >=0 and <= 100, there's no need to check again and say invalid. Just put an else at the end of your first if clause and then say Invalid. Also the else statement you have right now will always create a new line if the grade is less than 90 (which I don't understand the use of another line break if you already have cout << "\n";. Use brackets. Besides that, if you have any specific problems/errors/bugs, please describe them here and you'll get help.
• 11-04-2011
Alvaro Ryfkogel
Thank you guys for being so friendly and providing me with some support, I finished the program already. By the way I had to use the eof because the professor said we had to, oh well.
• 11-04-2011
Elysia
Then you should point out to your professor that it's wrong.