Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. import java.util.HashSet;
  2. import java.util.Scanner;
  3.  
  4. public class ParkingLot {
  5. public static void main(String[] args) {
  6. Scanner scanner=new Scanner(System.in);
  7.  
  8. String input = scanner.nextLine();
  9.  
  10. HashSet<String> paking = new HashSet<>();
  11.  
  12. while (!input.equalsIgnoreCase("end")){
  13. String[] splitInput = input.split(", ");
  14.  
  15. switch (splitInput[0]){
  16. case "IN":paking.add(splitInput[1]);
  17. break;
  18. case "OUT":paking.remove(splitInput[1]);
  19. break;
  20. default:return;
  21. }
  22.  
  23. input=scanner.nextLine();
  24. }
  25.  
  26. if (paking.isEmpty())
  27. System.out.println("Parking Lot is Empty");
  28. else{
  29. paking.forEach(carNum-> System.out.println(carNum));
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement