Getting wrong numbers

I am having difficulty with this program. I am supposed to using OOP and arrays.

My problem is that it comes back with over 200,000 F's when the input file doesn't even have that amount of lines.

Last edited on
an A is 90+
a B is 80-89
a C is 70-79
etc


The etc here is important. How many grades do you want? Your display function suggests 5, but you only allocate an array of size 4. Meanwhile, your constructor only initializes 3 grades.

Remember: Arrays start at index 0.

1
2
3
int array[5]; // 5 slots
array: [ A, B, C, D, F ]
index: [ 0, 1, 2, 3, 4 ]


1
2
3
4
5
6
const int Num_Grade_Letters = 5;
int array[Num_Grade_Letters];
for (int i = 0; i < 5; i++)
{
    array[i] = 0;
}
Last edited on
Thanks, Ganado. Just started arrays and you made it so simple. Thanks so much.
Do not remove the content of your post after your question has been answered. It's just selfish and an abuse of the forum.
Last edited on
Topic archived. No new replies allowed.