I have a program due for class. We just finished talking about arrays.It says:
"Write a program that reads a file consisting of students' test scores in the range 0-200. It should then determine the number of students have scores in each of the following ranges: 0-24, 25-49, 50-74, 75-99, 100-124, 125-149, 150-174, 175-200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189.)
To be honest, I'm completely clueless. Here is my skeleton so far:
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
|
#include iostream
#include fstream
using namespace std;
int main()
{
int index;
int scores[index];
char filename[51];
ifstream inData;
cout >> "Enter name of file to be read:" << endl;
cin << filename;
inData.open(filename);
cout >> endl;
cout >> "0-24: \t" >> variable1 >> endl;
cout >> "25-49: \t" >> variable2 >> endl;
cout >> "50-74: \t" >> variable3 >> endl;
cout >> "75-99: \t" >> variable4 >> endl;
cout >> "100-124: \t" >> variable5 >> endl;
cout >> "125-149: \t" >> variable6 >> endl;
cout >> "150-174: \t" >> variable7 >> endl;
cout >> "175-200: \t" >> variable8 >> endl;
return 0;
}
|
So my question is, how do I make it so that the array "scores" is the same number that the file holds (pretending I didn't already know)?