Calculate Judge Score help

Hello, I am having a problem finishing this program. I'm probably just making it harder than it has to be but I still can't get it. In the calcScore function, I have to calculate the three remaining scores after dropping the highest and lowest scores, but I don't know how exactly to go about doing it. If someone can please explain it to me, it would be greatly appreciated.

Here is my program:

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <iostream>
using namespace std;

void getJudgeData(int &);
void calcScore(int, int, int, int, int);
int findLowest(int, int, int, int, int);
int findHighest(int, int, int, int, int);

int main()
{
	int score1, score2, score3, score4, score5;
	
	cout << " Judge 1: " << endl;
	getJudgeData(score1);

	cout << "\n Judge 2: " << endl;
	getJudgeData(score2);

	cout << "\n Judge 3: " << endl;
	getJudgeData(score3);

	cout << "\n Judge 4: " << endl;
	getJudgeData(score4);

	cout << "\n Judge 5: " << endl;
	getJudgeData(score5);

	calcScore(score1, score2, score3, score4, score5);

}

void getJudgeData(int &refVar)
{
	cout << " What is the judge's score? ";
	cin >> refVar;
	while(refVar < 0 || refVar > 10)
	{
		cout << " The Judge cannot give a score lower than 0, or higher than 10.\n";
		cout << " What is the Judge's score? ";
		cin >> refVar;
	}
}

void calcScore(int score_1, int score_2, int score_3, int score_4, int score_5)
{
	cout << "\n The highest and lowest scores will be dropped." << endl;
	findLowest(score_1, score_2, score_3, score_4, score_5);
	findHighest(score_1, score_2, score_3, score_4, score_5);
	cout << "\n The remaining scores will be averaged. " << endl;
}

int findLowest(int num1, int num2, int num3, int num4, int num5)
{
	if(num1 < num2 && num1 < num3 && num1 < num4 && num1 < num5)
	{
		cout << " The lowest Judge score is " << num1 << endl;
		return num1;
	}
	else if(num2 < num3 && num2 < num4 && num2 < num5 && num2 < num1)
	{
		cout << " The lowest Judge score is " << num2 << endl;
		return num2;
	}
	else if(num3 < num4 && num3 < num5 && num3 < num1 && num3 < num2)
	{
		cout << " The lowest Judge score is " << num3 << endl;
		return num3;
	}
	else if(num4 < num5 && num4 < num1 && num4 < num2 && num4 < num3)
	{
		cout << " The lowest Judge score is " << num4 << endl;
		return num4;
	}
	else if(num5 < num1 && num5 < num2 && num5 < num3 && num5 < num4)
	{
		cout << " The lowest Judge score is " << num5 << endl;
		return num5;
	}

	return 0;
}

int findHighest(int num1, int num2, int num3, int num4, int num5)
{
	if(num1 > num2 && num1 > num3 && num1 > num4 && num1 > num5)
	{
		cout << " The highest Judge score is " << num1 << endl;
		return num1;
	}
	else if(num2 > num3 && num2 > num4 && num2 > num5 && num2 > num1)
	{
		cout << " The highest Judge score is " << num2 << endl;
		return num2;
	}
	else if(num3 > num4 && num3 > num5 && num3 > num1 && num3 > num2)
	{
		cout << " The highest Judge score is " << num3 << endl;
		return num3;
	}
	else if(num4 > num5 && num4 > num1 && num4 > num2 && num4 > num3)
	{
		cout << " The highest Judge score is " << num4 << endl;
		return num4;
	}
	else if(num5 > num1 && num5 > num2 && num5 > num3 && num5 > num4)
	{
		cout << " The highest Judge score is " << num5 << endl;
		return num5;
	}

	return 0;
}
Looking at it now, this is a really big program...
@illlojik
If was doing the program, I would have made the array global, so I can change it in the functions. That would have shortened to program, but I left it the way you had it, and passed only the array values. Here is the program.
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Judges Score.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;

int getJudgeData();
int findLowest(int, int, int, int, int);
int findHighest(int, int, int, int, int);

int main()
{
	int score[5];
	int x;
	float average = 0.0;

	for( x=0;x<5;x++)
	{
		cout << " Judge " << x+1 << ": " << endl;
		score[x]= getJudgeData();
	}
	cout << "\n The highest and lowest scores will be dropped." << endl;
	x = findLowest(score[0], score[1], score[2], score[3], score[4]);
	score[x]=-1;
	x = findHighest(score[0], score[1], score[2], score[3], score[4]);
	score[x]=-1;
	cout << "\n The remaining scores will be averaged. " << endl;
	for (x=0;x<5;x++)
	{
		if (score[x]>=0)
		{
			cout << " A counted Judges score was " << score[x] <<endl;
			average = average+score[x];
		}
	}
	average = average/3;
	cout << " The average of the Judge's scores was " << average << endl << endl;
	return 0;
}

int getJudgeData()
{
	int refVar;
	cout << " What is the judge's score? (0 to 10) ? : ";
	cin >> refVar;
	while(refVar < 0 || refVar > 10)
	{
		cout << " The Judge cannot give a score lower than 0, or higher than 10.\n";
		cout << " What is the Judge's score? ";
		cin >> refVar;
	}
	return refVar;
}


int findLowest(int num1, int num2, int num3, int num4, int num5)
{
	if(num1 < num2 && num1 < num3 && num1 < num4 && num1 < num5)
	{
		cout << " The lowest Judge's score was " << num1 << endl;
		return 0;
	}
	else if(num2 < num3 && num2 < num4 && num2 < num5 && num2 < num1)
	{
		cout << " The lowest Judge's score was " << num2 << endl;
		return 1;
	}
	else if(num3 < num4 && num3 < num5 && num3 < num1 && num3 < num2)
	{
		cout << " The lowest Judge's score was " << num3 << endl;
		return 2;
	}
	else if(num4 < num5 && num4 < num1 && num4 < num2 && num4 < num3)
	{
		cout << " The lowest Judge's score was " << num4 << endl;
		return 3;
	}
	else if(num5 < num1 && num5 < num2 && num5 < num3 && num5 < num4)
	{
		cout << " The lowest Judge's score was " << num5 << endl;
		return 4;
	}
	return 0;
}

int findHighest(int num1, int num2, int num3, int num4, int num5)
{
	if(num1 > num2 && num1 > num3 && num1 > num4 && num1 > num5)
	{
		cout << " The highest Judge's score was " << num1 << endl;
		return 0;
	}
	else if(num2 > num3 && num2 > num4 && num2 > num5 && num2 > num1)
	{
		cout << " The highest Judge's score was " << num2 << endl;
		return 1;
	}
	else if(num3 > num4 && num3 > num5 && num3 > num1 && num3 > num2)
	{
		cout << " The highest Judge's score was " << num3 << endl;
		return 2;
	}
	else if(num4 > num5 && num4 > num1 && num4 > num2 && num4 > num3)
	{
		cout << " The highest Judge's score was " << num4 << endl;
		return 3;
	}
	else if(num5 > num1 && num5 > num2 && num5 > num3 && num5 > num4)
	{
		cout << " The highest Judge's score was " << num5 << endl;
		return 4;
	}

	return 0;
}
I see what you did, but I'm supposed to keep getJudgeData as a reference int value
@illlojik
getJudgeData isn't an array, so I'm not sure how you can keep it as a reference. If you mean that you can't delete or change the inputs, that's different. Make two more ints. int lowest and int highest.Then where it has score[x]=-1;, just put lowest = x; and highest = x at the next one. In the loops, if you want all 5 printed, move cout << " A counted Judges score was " << score[x] <<endl; to just under the for (x=.. ..), or remove it, etc., and have the if statement as if ( score[x]!=lowest||score[x]!=highest) Then, only the three middle values will be counted and averaged.
Hope that helps..
Ooh ok, I see what you mean. Thanks for the tip :D
@illlojik
Forgot to mention, delete the two score[x]=-1; lines also.
Topic archived. No new replies allowed.