Hi, I am trying to find the lowest score out of a group of 5 but for some reason it keeps telling me my lowestScore variable is undeclared even though I set to equal to 0.
#include<iostream>
#include<string>
using namespace std;
//////////////////////////////////////
// Prototypes
//////////////////////////////////////
void displayWelcome();
void getPerformer(string&, int&, string&);
void getJudgesScores(double&, double&, double&, double&, double&);
double findLowest(double&, double&, double&, double&, double&);
int main()
{
//variables
string name;
int age = 0;
string talent;
double score1 = 0;
double score2 = 0;
double score3 = 0;
double score4 = 0;
double score5 = 0;
double lowestScore = 0;
//Call the functions
displayWelcome();
getPerformer(name, age, talent);
getJudgesScores(score1, score2, score3, score4, score5);
findLowest(score1, score2, score3, score4, score5);
return 0;
}
//////////////////////////////////////
// Function Definitions
//////////////////////////////////////
void displayWelcome()
{
cout << "Welcome to The National Star Search Competetion" << endl;
}
void getPerformer(string& tempName, int& tempAge, string& tempTalent)
{
cout << "May I have your name please" << endl;
cin >> tempName;
cout << "May I have your age please" << endl;
cin >> tempAge;
cout << "What is your talent?" << endl;
cin >> tempTalent;
cout << tempName << tempAge << tempTalent << endl;
}
void getJudgesScores(double& tempScore1, double& tempScore2, double& tempScore3, double& tempScore4, double& tempScore5)
{
cout << "What is the first score?" << endl;
cin >> tempScore1;
if (tempScore1 < 0 || tempScore1 > 10)
{
cout << tempScore1 << "is invalid" << endl;
cout << "Enter a score between 0 and 10" << endl;
cin >> tempScore1;
}
cout << "What is the second score?" << endl;
cin >> tempScore2;
if (tempScore2 < 0 || tempScore2 > 10)
{
cout << tempScore2 << "is invalid" << endl;
cout << "Enter a score between 0 and 10" << endl;
cin >> tempScore2;
}
cout << "What is the third score?" << endl;
cin >> tempScore3;
if (tempScore3 < 0 || tempScore3 > 10)
{
cout << tempScore3 << "is invalid" << endl;
cout << "Enter a score between 0 and 10" << endl;
cin >> tempScore3;
}
cout << "What is the fourth score?" << endl;
cin >> tempScore4;
if (tempScore4 < 0 || tempScore4 > 10)
{
cout << tempScore4 << "is invalid" << endl;
cout << "Enter a score between 0 and 10" << endl;
cin >> tempScore4;
}
cout << "What is the fifth score?" << endl;
cin >> tempScore5;
if (tempScore5 < 0 || tempScore5 > 10)
{
cout << tempScore5 << "is invalid" << endl;
cout << "Enter a score between 0 and 10" << endl;
cin >> tempScore5;
}
}
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
|
double findLowest(double& tempScore1, double& tempScore2, double& tempScore3, double& tempScore4, double& tempScore5)
{
while (tempScore1 < tempScore2 && tempScore1 < tempScore3 && tempScore1 < tempScore4 && tempScore1 < tempScore5)
{
lowestScore = tempScore1;
return lowestScore;
}
while (tempScore2 < 1 && tempScore2 < 3 && tempScore2 < tempScore4 && tempScore2 < tempScore5)
{
lowestScore = tempScore2;
return lowestScore;
}
while (tempScore3 < tempScore1 && tempScore3 < tempScore2 && tempScore3 < tempScore4 && tempScore3 < tempScore5)
{
lowestScore = tempScore3;
return lowestScore;
}
while (tempScore4 < tempScore1 && tempScore4 < tempScore2 && tempScore4 < tempScore3 && tempScore4 < tempScore5)
{
lowestScore = tempScore4;
return lowestScore;
}
while (tempScore5 < tempScore1 && tempScore5 < tempScore2 && tempScore5 < tempScore3 && tempScore5 < tempScore4)
{
lowestScore = tempScore5;
return lowestScore;
}
}
| |