Any help is appreciated..
package com.codegym.task.task08.task0829;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
Software update
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// List of family names and cities
HashMap<String, String> addresses = new HashMap<>();
while (true) {
String family = reader.readLine();
if (family.isEmpty()) break;
String city = reader.readLine();
addresses.put(city, family);
}
// Read the city
String search = reader.readLine();
String result = null;
for (Map.Entry<String, String> pair : addresses.entrySet()) {
if (pair.getKey().equals(search)) {
result = (String) pair.getValue();
}
}
System.out.println(result);
}
}