aneliabogeva

Cinema tickets

Nov 26th, 2020
422
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. import java.util.function.DoubleUnaryOperator;
  3.  
  4. public class CinemaTickets {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         String nameMovie = scanner.nextLine();
  8.         Integer total_student = 0;
  9.         Integer total_kid = 0;
  10.         Integer total_standard = 0;
  11.         Integer total_ticket = 0;
  12.  
  13.         while(!"Finish".equals(nameMovie)){
  14.             Integer counter_student = 0;
  15.             Integer counter_standard = 0;
  16.             Integer counter_kid = 0;
  17.             Integer total_counter = 0;
  18.             Integer free_places = Integer.parseInt(scanner.nextLine());
  19.             String type = scanner.nextLine();
  20.             while (!"End".equals(type)){
  21.                 if("student".equals(type)){
  22.                     counter_student += 1;
  23.                 }else if("standard".equals(type)){
  24.                     counter_standard += 1;
  25.                 }else if("kid".equals(type)){
  26.                     counter_kid += 1;
  27.                 }
  28.                 total_counter +=1;
  29.                 if(total_counter >= free_places){
  30.                     break;
  31.                 }else{
  32.                     type = scanner.nextLine();
  33.                 }
  34.             }
  35.             Double totalCounter = total_counter.doubleValue();
  36.             Double freePlaces = free_places.doubleValue();
  37.             Double capacity = ((totalCounter / freePlaces) * 100);
  38.             System.out.printf("%s - %.2f", nameMovie, capacity);
  39.             System.out.println("% full.");
  40.             total_kid += counter_kid;
  41.             total_standard += counter_standard;
  42.             total_student += counter_student;
  43.             total_ticket = total_standard + total_student + total_kid;
  44.             nameMovie = scanner.nextLine();
  45.         }
  46.         Double totalStudens = total_student.doubleValue();
  47.         Double totalStandard = total_standard.doubleValue();
  48.         Double totalKid = total_kid.doubleValue();
  49.         Double precentStudet = (totalStudens / total_ticket)*100;
  50.         Double precentStandard = (totalStandard / total_ticket)*100;
  51.         Double precentKid = (totalKid / total_ticket)*100;
  52.  
  53.         System.out.printf("Total tickets: %d\n",total_ticket);
  54.         System.out.printf("%.2f", precentStudet);
  55.         System.out.print("% student tickets.\n");
  56.         System.out.printf("%.2f", precentStandard);
  57.         System.out.print("% standard tickets.\n");
  58.         System.out.printf("%.2f", precentKid);
  59.         System.out.print("% kids tickets.\n");
  60.  
  61.     }
  62. }
  63.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×