Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- public class _03_HouseParty {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- List<String> listParty = new ArrayList<>();
- for (int i = 0; i < n; i++) {
- String input = scanner.nextLine();
- String[] data = input.split("\\s+");
- String name = data[0];
- String goingOrNot = data[2];
- if (data.length == 4){
- if (listParty.contains(name)){
- listParty.remove(name);
- } else {
- System.out.println(data[0] + " is not in the list!");
- }
- } else {
- if (!listParty.contains(name)){
- listParty.add(name);
- } else {
- System.out.println(data[0] + " is already in the list!");
- }
- }
- for (String name : listParty) {
- System.out.println(name);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement