Advertisement
John_IV

Untitled

Nov 18th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. public class E04ParkingLot {
  2.     public static void main(String[] args) {
  3.         Scanner sc = new Scanner(System.in);
  4.  
  5.         List<String> list = new ArrayList<>();
  6.         String[] input = sc.nextLine().split(", ");
  7.  
  8.         while (!input[0].equals("END")) {
  9.  
  10.             if (input[0].equals("IN")) {
  11.                 list.add(input[1]);
  12.             } else {
  13.                 list.remove(input[1]);
  14.             }
  15.  
  16.             input = sc.nextLine().split(", ");
  17.         }
  18.  
  19.         if (list.isEmpty()) {
  20.             System.out.println("Parking Lot is Empty");
  21.         } else {
  22.             list.forEach(System.out::println);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement