Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int seats, kidTickets = 0, studentTickets = 0, standardTickets = 0;
- String movie, category;
- while (!(movie = scanner.nextLine()).equals("Finish")) {
- seats = Integer.parseInt(scanner.nextLine());
- int counter = 0;
- for (int i = 0; i < seats; i++) {
- category = scanner.nextLine();
- if (category.equals("student")) {
- studentTickets++;
- } else if (category.equals("standard")) {
- standardTickets++;
- } else if (category.equals("kid")) {
- kidTickets++;
- } else {
- break;
- }
- counter++;
- }
- System.out.printf("%s - %.2f%% full.\n", movie, 1.0 * counter / seats * 100);
- }
- int sumTickets = standardTickets + studentTickets + kidTickets;
- System.out.printf("Total tickets: %d\n", sumTickets);
- System.out.printf("%.2f%% student tickets.\n", 1.0 * studentTickets / sumTickets * 100);
- System.out.printf("%.2f%% standard tickets.\n", 1.0 * standardTickets / sumTickets * 100);
- System.out.printf("%.2f%% kids tickets.\n", 1.0 * kidTickets / sumTickets * 100);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement