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 addresses
//List<String> addresses = new ArrayList<>();
HashMap<String,String> addresses = new HashMap<String,String>();
while (true) {
String family = reader.readLine();
String city = reader.readLine();
if (family.isEmpty() || city.isEmpty()){
break;
}
addresses.put(city,family);
}
// Read the house number
//int houseNumber = Integer.parseInt(reader.readLine());
String cityName = reader.readLine().toUpperCase();
String searched = "";
for (Map.Entry<String,String> entry : addresses.entrySet()){
if(entry.getKey().equals(cityName)){
searched = entry.getValue();
}
}
System.out.println(searched);
}
}
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 addresses
//List<String> addresses = new ArrayList<>();
HashMap<String,String> addresses = new HashMap<String,String>();
while (true) {
String family = reader.readLine();
String city = reader.readLine();
if (family.isEmpty() || city.isEmpty()){
break;
}
addresses.put(city,family);
}
// Read the house number
//int houseNumber = Integer.parseInt(reader.readLine());
String cityName = reader.readLine().toUpperCase();
String searched = "";
for (Map.Entry<String,String> entry : addresses.entrySet()){
if(entry.getKey().equals(cityName)){
searched = entry.getValue();
}
}
System.out.println(searched);
}
}