Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashSet;
- import java.util.Scanner;
- public class ParkingLot {
- public static void main(String[] args) {
- Scanner scanner=new Scanner(System.in);
- String input = scanner.nextLine();
- HashSet<String> paking = new HashSet<>();
- while (!input.equalsIgnoreCase("end")){
- String[] splitInput = input.split(", ");
- switch (splitInput[0]){
- case "IN":paking.add(splitInput[1]);
- break;
- case "OUT":paking.remove(splitInput[1]);
- break;
- default:return;
- }
- input=scanner.nextLine();
- }
- if (paking.isEmpty())
- System.out.println("Parking Lot is Empty");
- else{
- paking.forEach(carNum-> System.out.println(carNum));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement