Solution please
package com.codegym.task.task08.task0815;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
/*
Census
*/
public class Solution {
public static HashMap<String, String> createMap() {
//write your code here
HashMap<String, String> names = new HashMap<>();
names.put("James", "Allon");
names.put("Allon", "Jams");
names.put("Peace", "Good");
names.put("Ugochukwu", "Handsome");
names.put("Shedrack", "Ebenezer");
names.put("Charles", "Finny");
names.put("James", "Allon");
names.put("Abraham", "Allon");
names.put("James", "Patience");
names.put("James", "Allon");
return names;
}
public static int getSameFirstNameCount(HashMap<String, String> map, String name) {
//write your code here
int firstNameCount = 0;
for (Map.Entry<String, String> namePair : map.entrySet()) {
if (namePair.getValue().equalsIgnoreCase(name))
firstNameCount++;
}
return firstNameCount;
}
public static int getSameLastNameCount(HashMap<String, String> map, String lastName) {
//write your code here
int lastNameCount = 0;
for (Map.Entry<String, String> namePair : map.entrySet()) {
if (namePair.getKey().equalsIgnoreCase(lastName))
lastNameCount++;
}
return lastNameCount;
}
public static void main(String[] args) {
}
}