Advertisement
deyanmalinov

07. Fix Emails

Apr 2nd, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. package DPM;
  2.  
  3. import java.util.LinkedHashMap;
  4. import java.util.Map;
  5. import java.util.Scanner;
  6.  
  7. public class Main {
  8.     public static void main(String[] args) {
  9.         Scanner scan = new Scanner(System.in);
  10.         LinkedHashMap<String, String> contact = new LinkedHashMap<>();
  11.         String line = scan.nextLine();
  12.         while (!line.equals("stop")){
  13.             String fline = line;
  14.             String sLine = scan.nextLine();
  15.             String dotCom = sLine.substring(sLine.length()-2);
  16.             if (dotCom.equals("bg")){
  17.                 contact.put(fline, sLine);
  18.             }
  19.             line=scan.nextLine();
  20.         }
  21.         for (Map.Entry<String, String> entry : contact.entrySet()) {
  22.             System.out.println(entry.getKey() + " -> " +entry.getValue());
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement