Star Search Output issue

Hi all so I was writing a star search program, also known as the talent show program. My issue is I keep getting a zero for my output no matter my input. I put the instructions just in case if you need it. Any help is appreciated!
Thanks

A talent competition has 5 judges, each of whom awards a score between 0 and 10 to each performer. Fractional scores, such as 8.3 are allowed. A performer's final score is determined by dropping the highest and lowest score received, then averaging the 3 remaining scores. Write a program that uses this method to calculate a contestant's score. It should include the following functions:

void getJudgeData() -- This should ask the user for a judge's score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the 5 judges.

void calcScore() -- This should calculate and display the average of the 3 scores that remain after dropping the highest and lowest scores the performer received. This function should be called just once by main, and should be passed the 5 scores.

The last two functions, described below, should be called by calcScore, which uses the returned information to determine which of the scores to drop.

int findLowest() -- This should find and return the lowest of the 5 scores passed to it.

int findHighest() -- This should find and return the highest of the 5 scores passed to it.



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 "stdafx.h"
#include <iostream>
using namespace std;
void getJudgeData();
double calcScore();
double findLowest();
double findHighest();

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
The reason you always get '0' is because you never call the calcScore function. You read in your values but never do anything with them.

A couple of hints...

You're not calling functions correctly. For the correct pattern, see this:

http://www.cplusplus.com/doc/tutorial/functions/

calcScore returns the average score (with the top and bottom thrown out). You do not need to pass the average, total, highest and lowest values in as arguments. The prototype for this function should be something like:

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


The findLowest and findHighest functions will have nearly identical prototypes.

The calcScore function should declare total, lowest and highest as local members of the function--that is the only place those variables are needed.

Line 27 should be '||' just like in 34, 41, etc.

Edit: I just figured out what I think you were trying to do. Regardless, lines 24, 66 and 67 need to replace lines 5 - 7. Then you need to properly call those functions (before line 60 and in lines 66 and 67).
Last edited on
Topic archived. No new replies allowed.