SHARE
TWEET

Graduation pt.2

MartinGeorgiev Apr 4th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top