Conditional Statement (Mistake 2)

Refer to the following codes:

  1. <?php
  2. $mark = 60;
  3. if ($mark < 50){
  4. $grade = "D";
  5. }
  6. else if ($mark < 70){
  7. $grade = "C";
  8. }
  9. if ($mark < 80){
  10. $grade = "B";
  11. }
  12. if ($mark < 100){
  13. $grade = "A";
  14. }
  15. echo "The grade for $mark is $grade";
  16. ?>

The codes should output "The grade for 60 is C". However the codes' output is "The grade for 60 is A". Be the first to put your comments what is wrong with the codes.


最終更新日時: 2019年 02月 23日(Saturday) 10:11