Java Collections – Maps
CSCI-2467 Lab 13 – Java Collections – Maps
Background
You will base this lab on code that you wrote for Lab 9.
- Copy your Lab9 project folder and rename it Lab13.
- Open the Lab13 project in IntelliJ
- In the Project window of IntelliJ you will see the project is named: Lab13[Lab9]
- Left click on this project name. Then right click to select the context menu. Select Refactor and then Rename. Change the name in the dialog box from Lab9 to Lab13.
Assignment
You will modify your previous lab as follows:
The Surname class will be unchanged.
The loadCensusData() method in the Census class will change as follows:
- It will return a Map<String,Surname> collection.
- Instead of creating an array to store an array of Surname elements, create a HashMap<String,Surname> object.
- Instead of reading in the first one hundred surnames, you will read them all.
- As before, you will create and initialize Surname objects.
- For each line in the file (except the header line), you’ll add a key / value pair to the HashMap. The key is the surname string, and the value is the Surname object.
- The method will return the populated HashMap.
The Main class will change as follows:
- As before, make sure the returned list (this time a Map) is not null.
- In a loop prompt the user to type a surname
- Input the name string
- If the user types the sentinel value “quit” (any case), break out of the loop and end the program
- Check to see if the name that the user input is in the Map (convert it to upper case first)
- If it is not, tell the user that the name was not found
- If you find it, output a report with the name, rank,count, and proportion
We've got everything to become your favourite writing service
Money back guarantee
Your money is safe. Even if we fail to satisfy your expectations, you can always request a refund and get your money back.
Confidentiality
We don’t share your private information with anyone. What happens on our website stays on our website.
Our service is legit
We provide you with a sample paper on the topic you need, and this kind of academic assistance is perfectly legitimate.
Get a plagiarism-free paper
We check every paper with our plagiarism-detection software, so you get a unique paper written for your particular purposes.
We can help with urgent tasks
Need a paper tomorrow? We can write it even while you’re sleeping. Place an order now and get your paper in 8 hours.
Pay a fair price
Our prices depend on urgency. If you want a cheap essay, place your order in advance. Our prices start from $11 per page.