Question: Main.java x 1 import java.util.*; 2 3 4 v 5 V 6 class Main { www public static void main(String[] args) { /* Code

Main.java x 1 import java.util.*; 2 3 4 v 5 V 6 class Main { www public static void main(String[] args) { /* Code for testing HashMap hash_map = new HashMap (); hash_map.put(1, "John"); 7 8 hash_map.put(2, "Doe"); 9 hash_map.put(3, "James"); 10 11 12 13 hash_map.put(4, "Eric"); System.out.println(even (hash_map)); HashMap hash_map2 = new HashMap () 14 hash_map2.put(1, 30); 15 hash_map2.put(2, 40); 16 hash_map2.put(3, 50); 17 18 19 hash_map2.put(4, 60); System.out.println(average (hash_map2)); */ 20 } 21 22 //add your code here.... 23 24 25 } Hashing (50 points) a. Write a method that creates a list of all the values in a HashMap that are located at even keys. You will then sort that list (using Collections.sort) and return the sorted list. Call this method: even O Parameter(s): HashMap Returns: ArrayList O Given the map: {1: "a", 2: "x", 3: "c", 4: "d"}, the result should be list {"d", "X"} b. Write a method that gets the average of all the values in the HashMap. Call this method: average O Parameter(s): HashMap Returns: a double Given the map: {1:10, 2:20, 5:30, 7:40}, the result should be 25
Step by Step Solution
There are 3 Steps involved in it
Heres the updated code with the implementation of the even and average methods java import javautil class Main public static void mainString args Code ... View full answer
Get step-by-step solutions from verified subject matter experts
