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.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116`` ``````#include "stdafx.h" #include 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.