ChonoChonovUk

MovieTickets

May 26th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.08 KB | None | 0 0
  1. import java.util.HashMap;
  2. import java.util.Scanner;
  3.  
  4. public class MovieTickets {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         String movieName = scanner.nextLine();
  8.         int seats = Integer.parseInt(scanner.nextLine());
  9.         String ticketType = "";
  10.  
  11.         int idx = 0;
  12.         double stud = 0.0;
  13.         double stan = 0.0;
  14.         double kids = 0.0;
  15.         double result = stud + stan +kids;
  16.  
  17.  
  18.         HashMap<String, HashMap<String, String>> outerMap = new HashMap<String, HashMap<String,String>>();
  19.         HashMap<String, Double> innerMap = new HashMap<String, Double>();
  20.  
  21.  
  22.         String[] movie = new String[20];
  23.  
  24.  
  25.         while (!movieName.equals("Finish")) {
  26.  
  27.             seats = Integer.parseInt(scanner.nextLine());
  28.  
  29.             while (!ticketType.equals("End")) {
  30.                 ticketType = scanner.nextLine();
  31.                 if((stud + stan + kids) == seats) {
  32.                     break;
  33.                 }else if(ticketType.equals("student")) {
  34.                     stud++;
  35.                 }else if(ticketType.equals("standard")) {
  36.                     stan++;
  37.                 }else if(ticketType.equals("kid")) {
  38.                     kids++;
  39.                 }
  40.  
  41.  
  42.             }
  43.             movie[idx] = movieName;
  44.             result = result/seats*100;
  45.             stud = (stud/seats)*100;
  46.             stan = (stan/seats)*100;
  47.             kids = (kids/seats)*100;
  48.             innerMap.put("total", result);
  49.             outerMap.put(movie[idx], innerMap);
  50.             innerMap.put("student", stud);
  51.             outerMap.put(movie[idx], innerMap);
  52.             innerMap.put("standart", stan);
  53.             outerMap.put(movie[idx], innerMap);
  54.             innerMap.put("kids", kids);
  55.             outerMap.put(movie[idx], innerMap);
  56.             idx++;
  57.             movieName = scanner.nextLine();
  58.         }
  59.  
  60.         for(int i = 0; i<idx;idx++){
  61.             Double student = ((HashMap<String, String>)outerMap.get(movie[idx])).((HashMap<String,Double>)innerMap.get("student"));;
  62.         }
  63.     }
  64. }
Add Comment
Please, Sign In to add comment