Last active
August 29, 2015 14:15
-
-
Save Treevs/91094d88d2c76e511d92 to your computer and use it in GitHub Desktop.
My friend didn't think making an ABCDF grade calculator was possible taking a percentage (simplified without the percentage sign) and using a switch statement without making multiple cases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function gradeSwitch($var) { | |
$var2 = (int)($var/10); | |
echo $var." is a(n)"; | |
switch($var2) { | |
case 10: | |
case 9: | |
echo "A"; | |
break; | |
case 8: | |
echo "B"; | |
break; | |
case 7: | |
echo "C"; | |
break; | |
case 6: | |
echo "D"; | |
break; | |
default: | |
echo "F"; | |
break; | |
} | |
echo "<br>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment