Hello. I am new to C++ and i am stuck on a problem. The program I have continues to loop over and over and I can't seem to figure out why. If anyone can help I would greatly appreciate it. Here is what I have:
#include <iostream>
#include <iomanip>
#include<fstream>
using namespace std;
int main()
{
int grade, kount, average, max_score, min_score;
kount = 0;
ifstream inFile;
inFile.open("i:\\programming\\grades.txt");
inFile >> grade;
while (!inFile.eof()) {
if (grade >= 0 && grade <= 100)
kount += 1;
inFile.close();
cout << "\n\n\n Hit enter to continue...";
cin.get();
return 0;
}
Here is the assigment and the output:
Write a program to read in a collection of exam scores ranging in value from 0 to 100. Your program should sort the scores in ascending order and display them in a column. Each score should be followed by a word that indicates its category, such as "Invalid" or "Satisfactory". The program must also count and display 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 also 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. (Use notepad to enter the following data values and save them on your drive).
Your program should print output starting at the top of the screen with your name followed by some column headings to identify the output. Be sure to include remarks identifying the author, date written, and what the program does.