Advertisement
NastySwipy

Exam - 05 November 2017 - 04. External Evaluation

Mar 4th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2. $numStudents = intval(readline());
  3. $counterA = 0;
  4. $counterB = 0;
  5. $counterC = 0;
  6. $counterD = 0;
  7. $counterE = 0;
  8. for($i = 0; $i < $numStudents; $i++){
  9.     $points [] = floatval(readline());
  10. }
  11. foreach ($points as $key=>$val) {
  12.     if ($val >= 0 && $val < 22.5) {
  13.          $counterA ++;
  14.     }
  15.     if ($val >= 22.5 && $val < 40.5) {
  16.         $counterB ++;
  17.     }
  18.     if ($val >= 40.5 && $val < 58.5) {
  19.         $counterC ++;
  20.     }
  21.     if ($val >= 58.5 && $val < 76.5) {
  22.         $counterD ++;
  23.     }
  24.     if ($val >= 76.5 && $val <= 100) {
  25.         $counterE ++;
  26.     }
  27. }
  28. $sum = $counterA + $counterB + $counterC + $counterD + $counterE;
  29. echo sprintf("%.2f", $counterA / $sum * 100)."% poor marks\n";
  30. echo sprintf("%.2f", $counterB / $sum * 100)."% satisfactory marks\n";
  31. echo sprintf("%.2f", $counterC / $sum * 100)."% good marks\n";
  32. echo sprintf("%.2f", $counterD / $sum * 100)."% very good marks\n";
  33. echo sprintf("%.2f", $counterE / $sum * 100)."% excellent marks";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement