trouble with loop

Hey all I'm not sure whats wrong with my code but for some reason once the user enters the final exam grade it then loops back and asks the user for basal grade #1 instead of outputting total points and percentage score.Any ideas???
[
Last edited on
closed account (D80DSL3A)
That's happening because on line 68 you are calling all the functions again. They will prompt for input just like they did the first time they were called on lines 61-64.
Perhaps you should catch the return values from the functions when they are first called, then use those values in your calculation on line 68, or just add the values up as the functions are called.
You could replace lines 61-66 with the following:
1
2
3
4
5
6
grandTotal = calcBasal(grade);
grandTotal += calcApes(grade2);
grandTotal += calcQuiz(grade3);
grandTotal += calcMini(grade4);
cout << "Enter final exam grade (or a guess) (out of 100): ";
grandTotal += cin >> grade5;

Now there is no need for line 68. The values have been added together already.

Another issue: The functions don't make sense. For example, in calcBasal() you have this loop:
1
2
3
4
5
for (int x = 1; x <= 18; x++)
	{
		cout << "Enter BASAL grade #" << x << "(out of 100):";
		cin >> grade;
	}

The value of grade will be overwritten each time the loop iterates. You aren't saving 18 values here. All values but the last one entered are lost. Are you supposed to be adding up the entries?
Topic archived. No new replies allowed.