dakotaboy99 Posted June 13, 2014 Share Posted June 13, 2014 Hello, Im new to the fourm, and just started taking a intro programming class and cant figure this php out, any help? Create a PHP program that allows the user to enter in an integer value that represents the score of a test. Valid integer values are from 0 to 100 inclusive. Display the score (integer value) and the corresponding letter grade. The grade scale is 10 points. 100 – 90 A 89 – 80 B 79 – 70 C 69 -60 D Less than 59 F <?php $score = 79; Echo “$score”; if ($score > 89){ $letter = “A”; }elseif ($score > 79){ $letter = “ B”; } elseif ($score > 69){ $letter = “ C”; } elseif ($score > 59){ or < $letter = “ D”; >? This is how our teacher started it off and whanted us to finish Link to comment Share on other sites More sharing options...
davej Posted June 13, 2014 Share Posted June 13, 2014 What if your score is 3 ? Link to comment Share on other sites More sharing options...
dakotaboy99 Posted June 13, 2014 Author Share Posted June 13, 2014 <?php $score = 79; Echo “$score”; IF ($score > 89){ $letter = “A”;}ELSE IF ($score > 79){ $letter = “ B”;}ELSE IF ($score > 69){ $letter = “ C”;}ELSE IF ($score > 59){ $letter = “ D”;>? Not sure, the teacher didnt really teach us much, he basically said to teach yourself this problem, everyone in class didnt understand this Link to comment Share on other sites More sharing options...
davej Posted June 13, 2014 Share Posted June 13, 2014 See... http://www.php.net//manual/en/control-structures.else.php http://www.php.net//manual/en/control-structures.elseif.php Link to comment Share on other sites More sharing options...
thescientist Posted June 13, 2014 Share Posted June 13, 2014 please use code tags, I can't tell if you are just copy pasting incorrectly or your ending php tag is really broken. also, please tell us the problem is. what value are you expecting for $letter? what is actually happening? You start with score at 79. But you never test if the score could be 79 (or 89, or 69, etc). Make sure you understand your comparison operators. http://www.w3schools.com/php/php_operators.asp Link to comment Share on other sites More sharing options...
dakotaboy99 Posted June 13, 2014 Author Share Posted June 13, 2014 Im really lost, the teacher didnt really teach, that is the first part of the code he gave us and thats the question he wanted answered, so im really not sure how to begin or end, this was our 3rd class meeting Create a PHP program that allows the user to enter in an integer value that represents the score of a test. Valid integer values are from 0 to 100 inclusive. Display the score (integer value) and the corresponding letter grade. The grade scale is 10 points..... Link to comment Share on other sites More sharing options...
davej Posted June 14, 2014 Share Posted June 14, 2014 Well, you might want to spend a few hours browsing through the tutorial here... http://www.w3schools.com/php/default.asp Link to comment Share on other sites More sharing options...
dakotaboy99 Posted June 14, 2014 Author Share Posted June 14, 2014 Thanks for all the help, still a long way to go but, im slowly starting to get some of my code down and the right syntax ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now