**This question must be done using Java Eclipse** (Assignment) Write a zip code lookup program. Read a data set of 1,000+ zip codes and city names from a file that contains zip codes and city names in...




**This question must be done using Java Eclipse** (Assignment) Write a zip code lookup program. Read a data set of 1,000+ zip codes and city names from a file that contains zip codes and city names in Iowa in random order. Handle lookups by zip code and also reverse lookups by city name. Use a binary search for both lookups. Four files are provided with the assignment. I will post them below. 1. ZipLookup.java: class containing ma in method. No modification needed. 2. Item.java: class to store an item. Use string variable ‘key’ for zip code and string variable ‘value’ for city name. No modification needed. 3. LookupTable.java: core class of this assignment. Complete all methods. 4. iazip.txt: zip codes and city names in Iowa. Thank You! **Look upTable.java import java. util. Array List; java. util. Collections; import java. util. Scanner; /** * Code for HW6 * @author */ /** A table for lookups and reverse lookups */ public class Lookup Table { private Array List by Key; private Array List by Value; /**Constructs a Lookup Table object. */ public Lookup Table() { by Key = new Array List(); By Value = new Array List(); } /**Reads key/value pairs. @ param in the scanner for reading the input */ public void read(Scanner in) {. . . } /**Looks up an item in the table.@ param k the key to find @return the value with the given key, or null if no such item was found. */ public String lookup(String k) . . . } /** Looks up an item in the table. @ param v the value to find @return the key with the given value, or null if no such item was found. */ public String reverse Lookup(String v) { . . .} }**Zip Lookup. Java import java. io. IO Exception; import java. io. File Reader; import java. util. Scanner; /* The input file has the format 50001 ACKWORTH 50002 ADAIR 50003 ADEL 50005 ALBION 50006 ALDEN 50007 ALLEMAN 50008 . . . */ public class Zip Lookup { public static void main(String[] args) throws IO Exception { Scanner in = new Scanner(System. in); System. Out .print ln ("Enter the name of the zip code file: "); String file Name = in. Next Line(); Lookup Table table = new Lookup Table();File Reader reader = new File Reader (file Name table .read(new Scanner(reader)); boole an more = true; while (more) { System .out. print ln ("Lookup Z)ip, C)ity name, Q)uit?"); String cmd = in. Next Line(); if (cm .equal sIgnore Case("Q")) more = false; else if (cmd. Equal Si gnore Case("Z")) { System .out .print ln("Enter Zip code:"); String n = in. Next Line(); System. out. Print ln("City name: " + table. lookup(n) + "\n"); } else if (cmd. Equal sI gnore Case("C")) { System. out. Print ln ("Enter city name:"); String n = in. Next Line(); System .out. print ln ("Zip code: " + table .reverse Lookup(n)+ "\n");} } } **Item .java /** An item with a key and a value. */ public class Item implements Comparable { private String key; private String value; /** Constructs an Item object. @param k the key string @param v the value of the item */ public Item(String k, String v) { key = k; value = v; } /** Gets the key. @return the key */ public String get Key() { return key; } /** Gets the value. @return the value */ public String get Value() { return value; } public in t compare To(Item other Object) { Item other = (Item) other Object; return key. compare To(other. key); } } **iazip.txt 50001 ACKWORTH 50002 ADAIR 50003 ADEL 50005 ALBION 50006


May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here