MartinGeorgiev

06.Movie

Apr 19th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2.  
  3. $kid = 0;
  4. $students = 0;
  5. $standart = 0;
  6.  
  7. $movie = readline();
  8. while($movie !== 'Finish'){
  9.    
  10.     $seats = intval(readline());
  11.     $people = 0;
  12.     for($i = 0; $i < $seats; $i++){
  13.        $command = readline();
  14.         if($command === "kid"){
  15.             $kid++;
  16.         } else if($command === "student"){
  17.             $students++;
  18.         } else if($command === "standard"){
  19.             $standart++;
  20.         } else if($command === "End"){
  21.            break;
  22.         }
  23.          $people++;
  24.     }
  25.     $salon = $people / $seats * 100;
  26.     $formatCount = number_format($salon, '2', '.', '');
  27.     echo "$movie - $formatCount% full." .PHP_EOL;
  28.     $movie = readline();
  29. }
  30.  
  31. $sum = $kid + $students + $standart;
  32. $kidTicket = $kid / $sum * 100;
  33. $studentTicket = $students / $sum  * 100;
  34. $standartTicket = $standart / $sum  * 100;
  35.  
  36. $formatStudent = number_format($studentTicket, '2', '.', '');
  37. $formatStandard = number_format($standartTicket, '2', '.', '');
  38. $formatKid = number_format($kidTicket, '2', '.', '');
  39.  
  40. echo "Total tickets: $sum" .PHP_EOL;
  41. echo "$formatStudent% student tickets.".PHP_EOL;
  42. echo "$formatStandard% standard tickets.".PHP_EOL;
  43. echo "$formatKid% kids tickets.".PHP_EOL;
Add Comment
Please, Sign In to add comment