Advertisement
touhid_xml

Generate Grading in PHP by simple function

Apr 3rd, 2015
511
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function makeGrade($score) {
  4.     if($score>=80)
  5.         return 'A+';
  6.     if($score>=70)
  7.         return 'A';
  8.     if($score>=60)
  9.         return 'A-';
  10.     if($score>=50)
  11.         return 'B';
  12.     if($score>=40)
  13.         return 'C';
  14.     if($score>=33)
  15.         return 'D';
  16.  
  17.     return 'F';
  18. }
  19.  
  20. echo makeGrade( 80 ); //generate grade
  21. echo "<br />\n";
  22. echo makeGrade( 70 );//generate grade
  23. echo "<br />\n";
  24. echo makeGrade( 60 );//generate grade
  25. echo "<br />\n";
  26. echo makeGrade( 50 );//generate grade
  27. echo "<br />\n";
  28. echo makeGrade( 40 );//generate grade
  29. echo "<br />\n";
  30. echo makeGrade( 33 );//generate grade
  31. echo "<br />\n";
  32. echo makeGrade( 30 );//generate grade
  33. echo "<br />\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement