Function

Any help would be nice.
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
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
using namespace std;

double getJudgeScore (double judge);

int main()
{
	double judge;
	
	getJudgeScore(judge);

	return 0;
}

double getJudgeScore (double judge)
{
	int judgenumber = 1;

	while(judgenumber < 6)
	{
		cout << "Enter score from judge #" << judgenumber << ": ";
		cin >> judge;

		do
		{
			if(judge > -1 && judge <= 10)
			{
			return judge;
			judgenumber++;
			}
			else
			cout << "Score must be between 0 and 10. Please re-enter: ";
				cin >> judge;
		}
		while(judgenumber < 6);
	}
}



Enter score from judge #1: -1
Score must be between 0 and 10. Please re-enter: 5
Press any key to continue


For some reason it will not loop, I most likely don't have my loop set up right.


Enter score from judge #1: -1
Score must be between 0 and 10. Please re-enter: 11
Score must be between 0 and 10. Please re-enter: 8.23
Enter score from judge #2: 9.51
Enter score from judge #3: -8
Score must be between 0 and 10. Please re-enter: 8.67
Enter score from judge #4: 5.39
Enter score from judge #5: 9.75


This is what I want to happen. Again any help would be nice, and Thank You for your time.
closed account (1yvXoG1T)
It has to do with this little section
1
2
3
4
5
if(judge > -1 && judge <= 10)
{
	return judge;
	judgenumber++;
}


Here you're telling it to "return" to the main function with the value of judge. Only return AFTER you've collected all of the scores. And if you need to collect six different scores then you'll need some container to put them in (an array, vector, etc.)
Hope this helps.
Topic archived. No new replies allowed.