Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Lekciq;
- import java.util.HashSet;
- import java.util.Scanner;
- import java.util.Set;
- import java.util.TreeSet;
- public class SoftUniParty {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // Sets for VIP and regular guests
- Set<String> vipGuests = new HashSet<>();
- Set<String> regularGuests = new HashSet<>();
- // Reading reservation numbers until "PARTY"
- String input = scanner.nextLine();
- while (!input.equals("PARTY")) {
- if (Character.isDigit(input.charAt(0))) {
- vipGuests.add(input);
- } else {
- regularGuests.add(input);
- }
- input = scanner.nextLine();
- }
- // Reading arrival of guests until "END"
- input = scanner.nextLine();
- while (!input.equals("END")) {
- vipGuests.remove(input);
- regularGuests.remove(input);
- input = scanner.nextLine();
- }
- // Output the guests who didn't come
- int totalNoShows = vipGuests.size() + regularGuests.size();
- System.out.println(totalNoShows);
- // VIP guests first
- TreeSet<String> sortedVipGuests = new TreeSet<>(vipGuests);
- TreeSet<String> sortedRegularGuests = new TreeSet<>(regularGuests);
- sortedVipGuests.forEach(System.out::println);
- sortedRegularGuests.forEach(System.out::println);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement