CMSC 206: Data Structures
Assignment - Extra Credit

Due on Thursday, December 8 at 9:45a

 

Redo Assignment#3 (Extra Credit Version) using hash tables in Java.

  1. Write a program that reads all the data (as in Assignment#3) and stores it in a hash table (using Java HashMap). The <Key,Value> pairs will be <String, Place> where String will correspond to Town+State (for example, "Bryn MawrPA") and Place will be extended to store ALL the zip codes for a given place. After reading the data file, your program should print out the number of entries in the list.
  2. Write a program that, given a town name and its state, searches the list for the name of the town and state, and then prints out all the information it knows about it, in the following format:
   Query: Cambridge, MA
   Found...
   Town: Cambridge, MA, 02138 (Area Code: 617, Time Zone: Eastern)
   County: Middlesex, population 1367000

All input will be from the Console Window or you may set up a data file to search for the required entries below. All output will be in the Console Window.

For demonstrating the correctness of your program, include a printout that shows the output from following queries:

  1. Cambridge, MA
  2. Jim Thorpe, PA
  3. Your birth place (if in the US), or pick your favorite US town
  4. Bryn Mawr, PA
  5. Boring, OR
  6. Hell, MI
  7. Pie Town, NM
  8. Surprise, NY
  9. Joe, MT
  10. Romance, AR
  11. Mars, PA
  12. Okay, OK
  13. Rough and Ready, CA
  14. Accident, MD
  15. Good Grief, ID

To show your output cut and paste the contents of the Console Window in a text file and print it. Additionally, hand in a prinout of the complete Java program.

Important Notes:

1. This assignment is optional.
2. The deadline is firm. There will be no extensions granted under any circumstances.
3. Please, do not submit incomplete work. Only completed assignments will be graded.
4. The assignment will be graded (out of 0.0 to 4.0 scale) as a sixth assignment. The best five assignment grades will be counted towards your final grade in the course.

What to Hand-in:

  1. A complete printout of your program(s). Highlight/circle the place where you use HashMap, and any extensions you make to Place class.
  2. a prinout of your program showing the outputs from the queries above.

Back to CS206 Course Materials