.
package com.javarush.task.task08.task0815;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/*
Перепись населения
*/
public class Solution {
public static Map<String, String> createMap() {
Map<String, String> map = new HashMap<>();
map.put("Кузьмин", "Дмитрий");//1
map.put("Петров", "Павел");//2
map.put("Иванченко", "Юрий");//3
map.put("Петров", "Алексей");//4
map.put("Иванов", "Георгий");//5
map.put("Кузнецов", "Павел");//6
map.put("Кузьмин", "Александр");//7
map.put("Чехов", "Юрий");//8
map.put("Мишков", "Валентин");//9
map.put("Кузнецов", "Евгений");//10
return map;
}
public static int getCountTheSameFirstName(Map<String, String> map, String name) {
Iterator<Map.Entry<String,String>>iterator=map.entrySet().iterator();
int count =0;
for (Map.Entry<String,String>pair:map.entrySet()){
String Value = pair.getValue();
if (name.contains(Value)){
count++;
}
}
return count;
}
public static int getCountTheSameLastName(Map<String, String> map, String lastName) {
Iterator<Map.Entry<String,String>>iterator=map.entrySet().iterator();
int count=0;
for (Map.Entry<String,String>pair:map.entrySet()){
String Key = pair.getKey();
if (lastName.contains(Key)){
count++;
}
}
return count;
}
public static void main(String[] args) {
}
}