deyanmalinov

07. Fix Emails

Apr 2nd, 2020
94
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data