Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Scanner;
- public class MovieTickets {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String movieName = scanner.nextLine();
- int seats = Integer.parseInt(scanner.nextLine());
- String ticketType = "";
- int idx = 0;
- double stud = 0.0;
- double stan = 0.0;
- double kids = 0.0;
- double result = stud + stan +kids;
- HashMap<String, HashMap<String, String>> outerMap = new HashMap<String, HashMap<String,String>>();
- HashMap<String, Double> innerMap = new HashMap<String, Double>();
- String[] movie = new String[20];
- while (!movieName.equals("Finish")) {
- seats = Integer.parseInt(scanner.nextLine());
- while (!ticketType.equals("End")) {
- ticketType = scanner.nextLine();
- if((stud + stan + kids) == seats) {
- break;
- }else if(ticketType.equals("student")) {
- stud++;
- }else if(ticketType.equals("standard")) {
- stan++;
- }else if(ticketType.equals("kid")) {
- kids++;
- }
- }
- movie[idx] = movieName;
- result = result/seats*100;
- stud = (stud/seats)*100;
- stan = (stan/seats)*100;
- kids = (kids/seats)*100;
- innerMap.put("total", result);
- outerMap.put(movie[idx], innerMap);
- innerMap.put("student", stud);
- outerMap.put(movie[idx], innerMap);
- innerMap.put("standart", stan);
- outerMap.put(movie[idx], innerMap);
- innerMap.put("kids", kids);
- outerMap.put(movie[idx], innerMap);
- idx++;
- movieName = scanner.nextLine();
- }
- for(int i = 0; i<idx;idx++){
- Double student = ((HashMap<String, String>)outerMap.get(movie[idx])).((HashMap<String,Double>)innerMap.get("student"));;
- }
- }
- }
Add Comment
Please, Sign In to add comment