I'm Trying to write a function that asks the user for scores from Judges(5). After the Scores are retrieved by a function I'm trying to find the highest value from those 5 scores in a different function. Ive looked in my textbook and searched the internet for possible reasons my code is messed up but to no avail. Its not easy to apply someone else's situation to your code. But currently my double function(findHighest) is only returning 0 when displayed in the console. Any insight into why my findHighest function is only returning 0? Thanks
#include <iostream>
using namespace std;
//Prototypes
void getJudgeData(double& Judge, int i);
double findLowest(double, double, double, double, double);
double findHighest(double, double, double, double, double);
int main()
{
double Highest, Lowest, Judge, Judge1, Judge2, Judge3, Judge4, Judge5;
int i=1;
while (i <= 5)
{
getJudgeData(Judge, i);
if (i == 1)
Judge1 = Judge;
if (i == 2)
Judge2 = Judge;
if (i == 3)
Judge3 = Judge;
if (i == 4)
Judge4 = Judge;
if (i == 5)
{
Judge5 = Judge;
}
i++;
}
Highest = Highest;
cout << "Raw Scores: " << Judge1 << " " << Judge2 << " " << Judge3 << " " << Judge4 << " " << Judge5 << endl;
cout << "Lowest Score Dropped: " << Lowest << endl;
cout << "Highest Score Dropped: " << Highest << endl;
system("pause");
return 0;
}
void getJudgeData(double& Judge, int i)
{
cout << "Judge " << i << " Score: ";
cin >> Judge;
if (Judge < 0 || Judge > 10)
{
cout << "***Invalid Score***" << endl;
i--;
}
}
double findHighest(double& Judge1, double& Judge2, double& Judge3, double& Judge4, double& Judge5)
{
double Highest= Judge1;
if (Judge2 > Highest)
Highest = Judge2;
if (Judge3 > Highest)
Highest = Judge3;
if (Judge4 > Highest)
Highest = Judge4;
if (Judge5 > Highest)
Highest = Judge5;
return (double)Highest;
}