First of all, you wrote few details about your requirements about the outcome you want from this function. I checked your function and it have some major condition problem.
Now, if your requirement is to show "Grade: A" if someone gets 90 in any category (e.g, 90 in $talent or 90 in $physical or 90 in $entertainment etc.) then the function you wrote is working fine. All you need to do is initialize the function like:
function ovr_grade($talent, $physical, $entertainment, $reputation, $overness) {
if ($talent >= 90 || $physical >= 90 || $entertainment >= 90 || $reputation >= 90 || $overness >= 90) {
return "Grade: A";
} elseif ($talent >= 80 || $physical >= 80 || $entertainment >= 80 || $reputation >= 80 || $overness >= 80) {
return "Grade: B";
} elseif ($talent >= 70 || $physical >= 70 || $entertainment >= 70 || $reputation >= 70 || $overness >= 70) {
return "Grade: C";
} elseif ($talent >= 60 || $physical >= 60 || $entertainment >= 60 || $reputation >= 60 || $overness >= 60) {
return "Grade: D";
} elseif ($talent = 50 || $physical = 50 || $entertainment = 50 || $reputation = 50 || $overness >= 50) {
return "Grade: E";
} elseif ($talent <= 49 || $physical <= 49 || $entertainment <= 49 || $reputation <= 49 || $overness <= 49) {
return "Grade: F";
} else {
return "N/A";
}
}
echo ovr_grade(90,90,90,90,90);
Then you should get the desired result. But if you want to show "Grade: A" when someone gets 90 in all category, then you should edit your condition like below:
function ovr_grade($talent, $physical, $entertainment, $reputation, $overness) {
if ($talent >= 90 && $physical >= 90 && $entertainment >= 90 && $reputation >= 90 && $overness >= 90) {
return "Grade: A";
} elseif ($talent >= 80 && $physical >= 80 && $entertainment >= 80 && $reputation >= 80 && $overness >= 80) {
return "Grade: B";
} elseif ($talent >= 70 && $physical >= 70 && $entertainment >= 70 && $reputation >= 70 && $overness >= 70) {
return "Grade: C";
} elseif ($talent >= 60 && $physical >= 60 && $entertainment >= 60 && $reputation >= 60 && $overness >= 60) {
return "Grade: D";
} elseif ($talent = 50 && $physical = 50 && $entertainment = 50 && $reputation = 50 && $overness >= 50) {
return "Grade: E";
} elseif ($talent <= 49 && $physical <= 49 && $entertainment <= 49 && $reputation <= 49 && $overness <= 49) {
return "Grade: F";
} else {
return "N/A";
}
}
echo ovr_grade(90,90,90,90,90);
I guess this will help you out. If need anything more, dont hesitate to ask.
Thanks
$talent,$physical,$entertainment,$reputation
as a boolean value. You should restructure the code to($talent >= 90 || $physical >= 90 || $entertainment >= 90 || $reputation >= 90 || $overness >= 90)
if
statement.