Uninitialized local variable. Help.

I am writing a program that will find the average of 5 judges score subtracting the highest and lowest score. I am not allowed to use arrays on this assignment.
Everything seems functional except I keep getting C4700 compiler errors on lines 11-15. Any insight or help would be greatly appreciated.

[code]
Put the code you need help with here.
#include <iostream>
#include <iomanip>
using namespace std;

void getScore(double );
void calcAverage(double, double, double, double, double);
int findLowest(double, double, double, double, double);
int findHighest(double, double, double, double, double);
int main() {
double j1, j2 , j3 , j4 , j5 ;
getScore(j1);
getScore(j2);
getScore(j3);
getScore(j4);
getScore(j5);
calcAverage(j1, j2, j3, j4, j5);
}

void getScore(double)
{
cout << "Enter a judge score\n";
double score;
cin >> score;

while (score < 0 || score > 11)
{
cout << "Please enter a valid judge score that is between 0 to 10\n";
cin >> score;
}

}
void calcAverage(double s1, double s2, double s3, double s4, double s5)
{
double sum;
double lowest, highest;
double average;

highest = findHighest(s1, s2, s3, s4, s5);
lowest = findLowest(s1, s2, s3, s4, s5);

sum = s1 + s2 + s3 + s4 + s5 - (lowest + highest);
average = sum / 3.0;

cout << setw(4) << fixed << showpoint << setprecision(2);
cout << "Your score is: " << average << endl;
}
int findLowest(double s1, double s2, double s3, double s4, double s5)
{
double lowest = s1;


if (s2 < lowest)
{
lowest = s2;
}
if (s3 < lowest)
{
lowest = s3;
}
if (s4 < lowest)
{
lowest = s4;
}
if (s5 < lowest)
{
lowest = s5;
}

cout << "The lowest test score is: " << lowest << endl;

return lowest;
}

int findHighest(double s1, double s2, double s3, double s4, double s5)
{
double highest = s1;


if (s2 < highest)
{
highest = s2;
}
if (s3 < highest)
{
highest = s3;
}
if (s4 < highest)
{
highest = s4;
}
if (s5 < highest)
{
highest = s5;
}

cout << "The highest test score is: " << highest << endl;

return highest;
}
Please use coding tags (http://www.cplusplus.com/articles/jEywvCM9/)

Change void getScore(double); to void getScore(double &score);
Change
1
2
3
4
5
6
7
8
9
10
11
12
13
void getScore(double)
{
cout << "Enter a judge score\n";
double score;
cin >> score;

while (score < 0 || score > 11)
{
cout << "Please enter a valid judge score that is between 0 to 10\n";
cin >> score;
}

}

to
1
2
3
4
5
6
7
8
9
10
11
void getScore(double &score)
{
	cout << "Enter a judge score\n";
	cin >> score;

	while (score < 0 || score > 11)
	{
		cout << "Please enter a valid judge score that is between 0 to 10\n";
		cin >> score;
	}
}


-> Highest test score logic is wrong. It's not if(s2 < highest) it's if(s2 > highest)
-> Main function must return a value.
Thank you this worked!
Topic archived. No new replies allowed.