deyanmalinov

01. Parking Lot

May 27th, 2019
143
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.HashSet;
  2. import java.util.LinkedHashSet;
  3. import java.util.Scanner;
  4. import java.util.TreeSet;
  5.  
  6. public class Main {
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.         HashSet<String> parking = new HashSet<>();
  10.         String line;
  11.         while (!"END".equals(line=scan.nextLine())){
  12.             String[] nums = line.split(", ");
  13.             switch (nums[0]){
  14.                 case "IN":
  15.                     parking.add(nums[1]);
  16.                     break;
  17.                 case "OUT":
  18.                     parking.remove(nums[1]);
  19.             }
  20.         }
  21.         if (parking.isEmpty()){
  22.             System.out.println("Parking Lot is Empty");
  23.         }else {
  24.             for (String s : parking) {
  25.                 System.out.println(s);
  26.             }
  27.         }
  28.     }
  29. }
RAW Paste Data