Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $kid = 0;
- $students = 0;
- $standart = 0;
- $movie = readline();
- while($movie !== 'Finish'){
- $seats = intval(readline());
- $people = 0;
- for($i = 0; $i < $seats; $i++){
- $command = readline();
- if($command === "kid"){
- $kid++;
- } else if($command === "student"){
- $students++;
- } else if($command === "standard"){
- $standart++;
- } else if($command === "End"){
- break;
- }
- $people++;
- }
- $salon = $people / $seats * 100;
- $formatCount = number_format($salon, '2', '.', '');
- echo "$movie - $formatCount% full." .PHP_EOL;
- $movie = readline();
- }
- $sum = $kid + $students + $standart;
- $kidTicket = $kid / $sum * 100;
- $studentTicket = $students / $sum * 100;
- $standartTicket = $standart / $sum * 100;
- $formatStudent = number_format($studentTicket, '2', '.', '');
- $formatStandard = number_format($standartTicket, '2', '.', '');
- $formatKid = number_format($kidTicket, '2', '.', '');
- echo "Total tickets: $sum" .PHP_EOL;
- echo "$formatStudent% student tickets.".PHP_EOL;
- echo "$formatStandard% standard tickets.".PHP_EOL;
- echo "$formatKid% kids tickets.".PHP_EOL;
Add Comment
Please, Sign In to add comment