When asked to enter students grades, it only output the first number the amount of times that's consistent with how many numbers the user inputted. Why is it doing so? I could've sworn I coded this correctly.
This function makes no sense. You input the grade (a) once only, before the loop, and then you add the same grade to the vector every time. Shouldn't you be entering the grade every time round the loop?
When the user types in the student grades, it's the grades of one student. I just want it to output the same numbers that have been inputted by the user but instead I'm getting ridiculous numbers.
There aren't any lines where the user types in the student grade a second time. The basic idea it that it's typed all at once by the user & that's being done on line 4. For example:
Enter student grades, type done whenever you're finished: 83 72 79 94 done
I want my studentGrades function to mimic how my fillNames function works.
I give up. I'll just do it for you. This relies on you have a C++11 compiler, because it has to convert a string to an int (which is something you'd missed entirely) using std::stoi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
void studentGrades(vector<int>& g) {
int a;
string b;
cout << "Enter student grades, type done whenever you're finished: ";
while(true)
{
cin >> b; // GET NEXT VALUE FROM THE INPUT SET
if (b == "done")
{ break;}
else
{
// Not done, so assume this b is now a number, but of course it's a string,
// so we need to convert it into an int before we can store it
a = stoi(b);
g.push_back(a);
}
}
}