I've been working on a problem where I'm supposed to enter 5 types of scores for 10 students into 5 arrays. I think I'm making it way more complicated and messy than it needs to be and confusing myself in the process. I've started out with the code below but after entering the numbers, it starts over asking the same thing. Also, it won't quit when I enter -1, no matter where I put the code to tell it to stop when -1 is entered. Thoughts? Thanks!
There's a lot of different ways you can do this, but the above is not one I would choose. If it were ME, i would fill each array first. Think like you're the teacher and you're grading 5 different assignments, each of which had 10 students submit grades. I would use a for loop for each, and validate your input inside the loop.
for example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
for (int count = 0; count < hw1Array[hw1Size]; count++)
{
int score;
do
{
cout << "Homework #1 score for Student " << count +1 << " (or -1 to exit): ";
cin >> score;
if(score < 0 && score > 100){cout << "invalid score\n";} // remember you can get a 0 or a 100 on a test
hw1Array[count] = score;
}
while (score !=-1);
That may be a little off, after all I'm still a noob too, but I think it would work better.
That's what I first thought would work but if you did it the way you show, you would have to fill in all of the hw1 scores for each student then go to the hw2 then hw3, etc. The expected output is showing it asking for all the different scores for student 1 first then student 2 then student3. etc. so I couldn't figure out how to do it the way you show. That's where I started to get confused as to how to get into an array.