Overloading functions

Hi im making a program that takes the average of 5 judges and drops the highest and lowest to give a final score. I'm running into a problem where feedback is telling me "void calcScore() overloaded function differs by return type from double calcScore()"
Also getting error message saying "calcScore() redefinition return basic types"

Any advice would be helpful thanks everyone!





#include <iostream>
#include <cmath>
using namespace std;

//Function Prototypes.
void getJudgeData(double &); // Store in reference variables.
void calcScore(double); // Calculate and return the average of the 3 scores.
double findHighest(); // Find and return the highest of the 5 scores
double findLowest(); // Find and return the lowest of the 5 scores.


// Variables
double score1, // Variable for the judges score.
score2,
score3,
score4,
score5,
average, // The average of the finalscore.
lowest,
totalscore, // All five scores added up.
finalscore, // The score total after the highest and lowest have been subtracted.
highest;

int main()
{
getJudgeData(score1);
getJudgeData(score2);
getJudgeData(score3);
getJudgeData(score4);
getJudgeData(score5);
void calcScore();
cout << "The average score of the 5 judges is" << average << "\n";
return 0;
}
// Function used to get judge scores.
void getJudgeData(double &score)
{
do
{
cout << "Enter Judge's score: ";
cin >> score;
if ((score < 0) || (score > 10))
cout << "The score must be between 0 and 10 please try again.";
} while ((score < 0) || (score > 10));
}
// Function used to get average.
void calcScore(double)
{
double findLowest;
double findHighest;
double total, lowest, highest, average;
totalscore = (score1 + score2 + score3 + score4 + score5);
finalscore = (totalscore - lowest - highest);
average = finalscore / 3;
}
// Function used to find the lowest number.
double findLowest()
{
double score1, score2, score3, score4, score5, lowest;
if ((score1 < score2) && (score1 < score3) && (score1 < score4) && (score1 < score5))
score1 = lowest;
else if ((score2 < score1) && (score2 < score3) && (score2 < score4) && (score2 < score5))
score2 = lowest;
else if ((score3 < score1) && (score3 < score2) && (score3 < score4) && (score3 < score5))
score3 = lowest;
else if ((score4 < score1) && (score4 < score2) && (score4 < score3) && (score4 < score5))
score4 = lowest;
else if ((score5 < score1) && (score5 < score2) && (score5 < score3) && (score5 < score4))
score5 = lowest;
return lowest;
}
//Function used to find the highest number.
double findHighest()
{
double score1, score2, score3, score4, score5, highest;
if ((score1 > score2) && (score1 > score3) && (score1 > score4) && (score1 > score5))
score1 = highest;
else if ((score2 > score1) && (score2 > score3) && (score2 > score4) && (score2 > score5))
score2 = highest;
else if ((score3 > score1) && (score3 > score2) && (score3 > score4) && (score3 > score5))
score3 = highest;
else if ((score4 > score1) && (score4 > score2) && (score4 > score3) && (score4 > score5))
score4 = highest;
else if ((score5 > score1) && (score5 > score2) && (score5 > score3) && (score5 > score4))
score5 = highest;
return highest;
}
Your prototype says calcScore takes a double in the arguments.

In main you try to call calcScore like void calcScore(); when it should be something like calcScore(someDouble);

When you define calcScore you did not name your arguments. This void calcScore(double) to something like void calcScore(double someNum)
Topic archived. No new replies allowed.