Advertisement
Guest User

Untitled

a guest
Aug 16th, 2020
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.02 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Zadacha7 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String movieName = scanner.nextLine();
  8.         int freeSpaces = Integer.parseInt(scanner.nextLine());
  9.         String type = scanner.nextLine();
  10.  
  11.         double counter = 0;
  12.         double counterTotal = 0;
  13.         double hall = 0;
  14.  
  15.         double kidCount = 0;
  16.         double kidPercent = 0;
  17.  
  18.         double standardCount = 0;
  19.         double standardPercent = 0;
  20.  
  21.         double studentCount = 0;
  22.         double studentPercent = 0;
  23.  
  24.  
  25.         while (!(movieName.equals("Finish"))) {
  26.             while (!(type.equals("End"))) {
  27.                 if (freeSpaces <= counter) {
  28.                     break;
  29.                 }
  30.                 counter++;
  31.                 counterTotal++;
  32.                 if (type.equals("kid")) {
  33.                     kidCount++;
  34.                 } else if (type.equals("standard")) {
  35.                     standardCount++;
  36.                 } else if (type.equals("student")) {
  37.                     studentCount++;
  38.                 }
  39.                 type = scanner.nextLine();
  40.             }
  41.             hall = (100.00 / freeSpaces) * counter;
  42.             System.out.printf("%s - %.2f%% full.%n", movieName, hall);
  43.             if (type.equals("Finish")) {
  44.                 break;
  45.             }
  46.  
  47.             counter = 0;
  48.             movieName = scanner.nextLine();
  49.             freeSpaces = Integer.parseInt(scanner.nextLine());
  50.             type = scanner.nextLine();
  51.         }
  52.  
  53.         System.out.printf("Total tickets: %.0f%n", counterTotal);
  54.  
  55.         studentPercent = (100 / counterTotal) * studentCount;
  56.         System.out.printf("%.2f%% student tickets.%n", studentPercent);
  57.  
  58.         standardPercent = (100 / counterTotal) * standardCount;
  59.         System.out.printf("%.2f%% standard tickets.%n", standardPercent);
  60.  
  61.         kidPercent = (100 / counterTotal) * kidCount;
  62.         System.out.printf("%.2f%% kids tickets.", kidPercent);
  63.  
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement