Star Search

I have to write a program that will take the score of 5 judges and then drop the highest and lowest and then out put the average of the remaining three. This is what I have so far, but the average keeps showing as 0.

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
#include <iostream>
using namespace std;
void getJudgeData();
double calcScore();
double findLowest();
double findHighest();
double calcScore(double score1, double score2, double score3, double score4, double score5);

int main()

{

getJudgeData();
	return 0;
}

void getJudgeData()
{
	double score1, score2, score3, score4, score5;
	double average = 0;
	double total = 0;
	double lowest = 0;
	double highest = 0;
	double calcScore(double, double, double, double, double, double, double, double, double);
	cout <<"Judge 1 Score: ";
	cin >> score1;
	if ( score1 < 0 || score1 > 10)
{
	cout <<"Re-Enter Score: ";
	cin >> score1;
}
	cout <<"Judge 2 Score: ";
	cin >> score2;
	if ( score2 < 0 || score2 > 10)
{
	cout <<"Re-Enter Score: ";
	cin >> score2;
}
	cout <<"Judge 3 Score: ";
	cin >> score3;
	if ( score3 < 0 || score3 > 10)
{
	cout <<"Re-Enter Score: ";
	cin >> score3;
}
	cout <<"Judge 4 Score: ";
	cin >> score4;
	if ( score4 < 0 || score4 > 10)
{
	cout <<"Re-Enter Score: ";
	cin >> score4;
}
	cout <<"Judge 5 Score: ";
	cin >> score5;
	if ( score5 < 0 || score5 > 10)
{
	cout <<"Re-Enter Score: ";
	cin >> score5;
}
 cout << "The average score is " << average << endl;
}

double calcScore(double average, double total, double highest, double lowest, double score1, double score2, double score3, double score4, double score5)

{
	double findLowest(double, double, double, double, double);
	double findHighest(double, double, double, double, double);
	total = score1 + score2 + score3 + score4 + score5;
	average = (total - highest - lowest) /3;
	return average;
}

double findLowest( double lowest, double score1, double score2, double score3, double score4, double score5)

{
	lowest = score1;
	if (score2 < score1)
{
	lowest = score2;
}
	if (score3 < score1)
{
	lowest = score3;
}
	if (score4 < score1)
{
	lowest = score4;
}
	if (score5 < score1)
{
	lowest = score5;
}
	return lowest;
}

double findHighest(double highest, double score1, double score2, double score3, double score4, double score5)
{
	highest = score1;
	if (score2 > score1)
{
	highest = score2;
}
	if (score3 > score1)
{
	highest = score3;
}
	if (score4 > score1)
{
	highest = score4;
}
	if (score5 > score1)
{
	highest = score5;
}
	return highest;
}

Last edited on
Topic archived. No new replies allowed.