Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. package com.javarush.task.task08.task0829;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.*;
  7.  
  8. /*
  9. Модернизация ПО
  10. */
  11.  
  12. public class Solution {
  13. public static void main(String[] args) throws IOException {
  14. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  15.  
  16. Map<String, String> map = new HashMap<>();
  17.  
  18. while (true) {
  19. String lastName = reader.readLine();
  20. String city = reader.readLine();
  21. if (lastName.isEmpty() || city.isEmpty()){
  22. break;
  23. }
  24. map.put(lastName, city);
  25. }
  26.  
  27. String nowCity = reader.readLine();
  28.  
  29. Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator();
  30.  
  31. while (iterator.hasNext()){
  32. Map.Entry<String, String> pair = iterator.next();
  33. if (pair.getValue().equals(nowCity)){
  34. System.out.println(pair.getKey());
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement