SHARE
TWEET

Untitled

a guest Jan 24th, 2020 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.LinkedHashMap;
  2. import java.util.Map;
  3. import java.util.Scanner;
  4.  
  5. public class FixEmails_v2 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String name = scanner.nextLine();
  10.  
  11.  
  12.         Map<String,String> maps = new LinkedHashMap<>();
  13.  
  14.         while (true){
  15.             if (name.equals("stop")){
  16.                 break;
  17.             }
  18.             String email = scanner.nextLine();
  19.  
  20.             if (!maps.containsKey(name)){
  21.                 if (!email.endsWith("uk") && !email.endsWith("us") && !email.endsWith("com")) {
  22.                     maps.put(name,email);
  23.                 }
  24.                
  25.  
  26.             }
  27.             name = scanner.nextLine();
  28.         }
  29.         for (Map.Entry<String, String> entry : maps.entrySet()) {
  30.             System.out.printf("%s -> %s%n", entry.getKey(),entry.getValue());
  31.         }
  32.     }
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top