Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Zadacha7 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String movieName = scanner.nextLine();
- int freeSpaces = Integer.parseInt(scanner.nextLine());
- String type = scanner.nextLine();
- double counter = 0;
- double counterTotal = 0;
- double hall = 0;
- double kidCount = 0;
- double kidPercent = 0;
- double standardCount = 0;
- double standardPercent = 0;
- double studentCount = 0;
- double studentPercent = 0;
- while (!(movieName.equals("Finish"))) {
- while (!(type.equals("End"))) {
- if (freeSpaces <= counter) {
- break;
- }
- counter++;
- counterTotal++;
- if (type.equals("kid")) {
- kidCount++;
- } else if (type.equals("standard")) {
- standardCount++;
- } else if (type.equals("student")) {
- studentCount++;
- }
- type = scanner.nextLine();
- }
- hall = (100.00 / freeSpaces) * counter;
- System.out.printf("%s - %.2f%% full.%n", movieName, hall);
- if (type.equals("Finish")) {
- break;
- }
- counter = 0;
- movieName = scanner.nextLine();
- freeSpaces = Integer.parseInt(scanner.nextLine());
- type = scanner.nextLine();
- }
- System.out.printf("Total tickets: %.0f%n", counterTotal);
- studentPercent = (100 / counterTotal) * studentCount;
- System.out.printf("%.2f%% student tickets.%n", studentPercent);
- standardPercent = (100 / counterTotal) * standardCount;
- System.out.printf("%.2f%% standard tickets.%n", standardPercent);
- kidPercent = (100 / counterTotal) * kidCount;
- System.out.printf("%.2f%% kids tickets.", kidPercent);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement