SHARE
TWEET

Untitled

a guest Jan 24th, 2020 64 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 U7FixEmails {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String name = scanner.nextLine();
  10.         String email = scanner.nextLine();
  11.  
  12.         Map<String,String> maps = new LinkedHashMap<>();
  13.  
  14.         while (true){
  15.  
  16.             if (!maps.containsKey(name)){
  17.                 if (!email.endsWith("uk") && !email.endsWith("us") && !email.endsWith("com")) {
  18.                     maps.put(name,email);
  19.                 }
  20.                 name = scanner.nextLine();
  21.  
  22.             }
  23.             if (name.equals("stop")){
  24.                 break;
  25.             }
  26.             email = scanner.nextLine();
  27.  
  28.  
  29.  
  30.  
  31.         }
  32.         for (Map.Entry<String, String> entry : maps.entrySet()) {
  33.             System.out.printf("%s -> %s%n", entry.getKey(),entry.getValue());
  34.         }
  35.     }
  36. }
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