Advertisement
MartinGeorgiev

Graduation pt.2

Apr 4th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. <?php
  2.  
  3. $name = readline();
  4. $counter = 1;
  5. $sum = 0;
  6. $excluded = 0;
  7. $isExcluded = FALSE;
  8. while ($counter <= 12) {
  9.     $grade = floatval(readline());
  10.     if ($grade < 4) {
  11.         $excluded++;
  12.     } else if ($grade >= 4 && $grade <= 6) {
  13.         $sum += $grade;
  14.         $counter++;
  15.     }
  16.     if ($excluded >= 2) {
  17.         $isExcluded = TRUE;
  18.         break;
  19.     }
  20. }
  21. if ($isExcluded == FALSE) {
  22.     $avarage = $sum / 12;
  23.     printf("$name graduated. Average grade: %0.2f", $avarage);
  24. } else {
  25.     echo "$name has been excluded at $counter grade";
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement