Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $command = readline(); //Rocky 4
- $kid = 0;
- $standard = 0;
- $student = 0;
- $total = 0;
- while ($command != "Finish") {
- $count = intval(readline());
- $current = 0;
- for ($i = 0; $i < $count; $i++) {
- $type = readline(); //student
- if ($type == "End") {
- break;
- } else if ($type == "kid") {
- $kid++;
- $current++;
- } else if ($type == "standard") {
- $standard++;
- $current++;
- } else if ($type == "student") {
- $student++;
- $current++;
- }
- }
- $total += $current;
- $percent = $current / $count * 100;
- $format = number_format($percent, 2, '.', '');
- //Taxi - 60.00% full.
- echo "$command - $format% full." . PHP_EOL;
- $command = readline();
- }
- $studentPer = number_format($student / $total * 100, 2, '.', '');
- $standardPer = number_format($standard / $total * 100, 2, '.', '');
- $kidPer = number_format($kid / $total * 100, 2, '.', '');
- echo "Total tickets: $total" . PHP_EOL;
- echo "$studentPer% student tickets." . PHP_EOL;
- echo "$standardPer% standard tickets." . PHP_EOL;
- echo "$kidPer% kids tickets." . PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement