here is my main method, and when i call to Print status. I set the params for PrintStatus and I'm getting an error about eligibility not being used and I cannot figure it out. I'm new to passing arguments, we just went over it in class.
"Error CS0165 Use of unassigned local variable 'eligibility' Program10 I:\Program10\Program10\Program10.cs 150 Active "
static void Main()
{
int id, age, exp;
double avgAge, avgExp;
char type;
string eligibility;
OpenFiles();
PrintReportHeadings();
while ((lineIn = fileIn.ReadLine()) != null)
{
ParseLineIn(out id, out type, out age, out exp);
PrintStatus(type, age, exp, eligibility);
PrintDetailLine(id, type, age, exp);
}
CloseFiles();
}
not sure how to fix this..
static void PrintStatus(char type, int age, int exp, string eligibility)
{
switch (type)
{
case 'm':
case 'M':
if (age < 55 && exp < 20)
eligibility = ("lack of experience age");
else if (age >= 55 && exp >= 20)
eligibility = ("can retire");
else if (age >= 55 && exp < 20)
eligibility = ("lack of experience");
else if (age < 55 && exp >= 20)
eligibility = ("underage");
else
eligibility = ("Your entry is invalid");
break;
case 'w':
case 'W':
if (age < 63 && exp < 25)
eligibility = ("lack of exp age");
else if (age >= 63 && exp >= 25)
eligibility = ("can retire");
else if (age >= 63 && exp < 25)
eligibility = ("lack of exp");
else if (age < 63 && exp >= 25)
eligibility = ("lack age");
else
eligibility = ("Your entry is invalid");
break;
case 's':
case 'S':
if (age < 60 && exp < 24)
eligibility = ("lack of exp age");
else if (age >= 60 && exp >= 24)
eligibility = ("can retire");
else if (age >= 60 && exp < 24)
eligibility = ("lack of exp");
else if (age < 60 && exp >= 24)
eligibility = ("underage");
else
eligibility = ("Your entry is invalid");
break;
}
}
eligibilityinPrintStatusdon't affect your local variable namedeligibilityinMain? It sounds like yourPrintStatusmethod should be calledGetEligibility, and return a string...