Question: How would I solve this lookup program for university and zip code. It needs to read a data set of 2700+ universities and their zip

How would I solve this lookup program for university and zip code. It needs to read a data set of 2700+ universities and their zip codes from the given text file (university.txt). Handle lookups by zip code (lookup_by_zip method) and also lookup by university name (lookup_by_university method). It also needs to use a binary search for both lookups. A sample run is attached also.

How would I solve this lookup program for university and zip code.It needs to read a data set of 2700+ universities and their

*LookupTable.java 23 |tem.java UninipLookupProgram.java university.txt 9 public class LookupTable { 10 private ArrayList Zip_key; 11 private ArrayList University_key; 12 139 /** 14 * Constructs a LookupTable object. 15 *l 169 public LookupTable() { 17 // Two array lists are created. 18 Zip_key = new ArrayList(); // Zip is the key in this array list 19 University_key = new ArrayList(); // University is the key in this array list 20 } 219 /** 22 * Reads key/value pairs. Given the Scanner object "in", the method should read 23 * the input file. Write a while loop to read the text file attached 24 * ("university.txt"). Tip1: You can read two lines in one iteration of the 25 * while loop. The first and second lines are for university and zip, 26 * respecively Tip2: sort the arraylist of Item objects after reading all data 27 * 28 * @param in: the scanner for reading the input 29 *l 369 public void read(Scanner in) { 31 ll COMPLETE this method 32 while(there is a new line to read) { 33 I! read next line > university name 34 I! read next line > zip 35 // create item object 1: (zip,university) zip is the key 36 If create item object 2: (university,zip) university is the key 37 I! insert iteml to Zip_key 38 // insert item2 to University_key 39 } 4O // sort Zip_key, University_key } 429 /** 43 * Looks up an item in the table. This method returns a university for the given 44 * zip code. 45 * 46 * @param zip: zip code to search 47 * @return a university name for the given zip, or null if zip does not have a 48 * university. 49 *l 509 public String lookup_by_zip(String zip) { 51 // COMPLETE this method 52 53 fl int pos = Collections.binarySearch( 54 if p05

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!