map =MakeMap.makeMap(new Scanner (System.in));List names = new ArrayList (map.keySet ());Collections. sort(names);for(String name : names)System.out.println(name +has number "+...


Create a class called MakeMap with a single static method called makeMap(). The method should take as a parameter a Scanner so that it can read input using next() and nextInt().<br>The method should create a map which maps Strings to Integers based on the Scanner input and then returns that map. Your method would be called by the following program:<br>import java.util.Scanner;<br>import java.util.Map;<br>import java.util.List;<br>import java.util.ArrayList;<br>import java.util.Collections;<br>public class Main<br>{<br>public static void main(String [] args)<br>{<br>Map<String, Integer> map =<br>MakeMap.makeMap(new Scanner (System.in));<br>List<String> names = new ArrayList<String>(map.keySet ());<br>Collections. sort(names);<br>for(String name : names)<br>System.out.println(name +<br>has number

Extracted text: Create a class called MakeMap with a single static method called makeMap(). The method should take as a parameter a Scanner so that it can read input using next() and nextInt(). The method should create a map which maps Strings to Integers based on the Scanner input and then returns that map. Your method would be called by the following program: import java.util.Scanner; import java.util.Map; import java.util.List; import java.util.ArrayList; import java.util.Collections; public class Main { public static void main(String [] args) { Map map = MakeMap.makeMap(new Scanner (System.in)); List names = new ArrayList(map.keySet ()); Collections. sort(names); for(String name : names) System.out.println(name + has number " + map.get(name)); } } To summarize, you write the MakeMap class with a static method makeMap(). You need to read the input using the Scanner object which you receive as a parameter. You need to create and return the map which maps strings to numbers. Note that your program is passed the Scanner on the command line. You do not need to create a Scanner. Requested files MakeMap.java public class MakeMap { // No main method required. } 1 3 4
Jun 02, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here