**THIS METHOD TAKES COURSE AND EXP AND GIVES BACK RATING ** USER ENTERS HIGH QUALIFICATION AND EXP AND IT GIVIES RATING PLEASE HELP ME WITH THIS
public double Rating(string HQ, int exp)
{
double rating = 0;
if (HQ == "BTECH" && exp == 3 || exp == 4 || exp == 5)
{
rating = 3;
}
else if (HQ == "MTECH" && exp == 3 || exp == 4 || exp == 5)
{
rating = 4;
}
else if (HQ == "BCA" && exp == 3 || exp == 4 || exp == 5)
{
rating = 2;
}
else if (HQ == "MCA" && exp == 3 || exp == 4 || exp == 5)
{
rating = 3;
}
else if (HQ == "MSC" && exp == 3 || exp == 4 || exp == 5)
{
rating = 3.5;
}
else if (HQ == "BTECH" && exp > 5)
{
rating = 6;
}
else if (HQ == "MTECH" && exp > 5)
{
rating = 8;
}
else if (HQ == "BCA" && exp > 5)
{
rating = 4;
}
else if (HQ == "MCA" && exp > 5)
{
rating = 6;
}
else if (HQ == "MTECH" && exp > 5)
{
rating = 8;
}
else if (HQ == "MSC" && exp > 5)
{
rating = 7;
}
else if (HQ == "PHD" && exp > 5)
{
rating = 9;
}
return rating;
}
Please check out my CODE I do not like all the above if-else statements and believe that there is a cleaner way to write this. How could I refactor it?
Aucun commentaire:
Enregistrer un commentaire