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:

Don't use plagiarized sources. Get Your Custom Essay on
Java Collections – Maps
Just from $13/Page
Order Essay

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

 

Homework Writing Bay
Calculator

Calculate the price of your paper

Total price:$26
Our features

We've got everything to become your favourite writing service

Need a better grade?
We've got you covered.

Order your paper