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

Appendix A: sample run Lookup by (Z)ip, (U)niversity, (Q)uit? z Enter Zipcode : 50011 University in zip 50011 = IOWA STATE UNIVERSITY Lookup by (Z)ip, (U)niversity, (Q)uit? U Enter University : University of Iowa Zip of University of Iowa = 52242 Lookup by (Z)ip, (U)niversity, (Q)uit? z Enter Zipcode : 50010 University in zip 50010 = null Lookup by (Z)ip, (U)niversity, (Q)uit? U Enter University : Ames State University Zip of Ames State University = null Lookup by (Z)ip, (U)niversity, (Q)uit? z Enter Zipcode : 50614 University in zip 50614 = UNIVERSITY OF NORTHERN IOWA Lookup by (Z) ip, (U)niversity, (Q)uit? Q8 *l 9 public class LookupTable { 16 private ArrayList Zip_key; 11 private ArrayList University_key; 12 139 l** 14 * Constructs a LookupTable object. 15 */ 16C) 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 26 } 21 229 l** 23 * Reads key/value pairs. Given the Scanner object "in", the method should read 24 * the input file. Write a while loop to read the text file attached 25 * ("university.txt"). Tip1: You can read two lines in one iteration of the 26 * while loop. The first and second lines are for university and zip, 27 * respecively Tip2: sort the arraylist of Item objects after reading all data 28 * 29 * @param in: the scanner for reading the input 36 */ 31C) public void read(Scanner in) { 32 // COMPLETE this method 33 } 34 356 l** 36 * Looks up an item in the table. This method returns a university for the given 37 * zip code. 38 * 39 * @param zip: zip code to search 46 * @return a university name for the given zip, or null if zip does not have a 41 * university. 42 *I 439 public String lookup_by_zip(String zip) { 44 // COMPLETE this method 45 } 46 479 l** 48 * Looks up an item in the table. This method returns a zip code for the given 49 * university 5O * 51 * @param univ: university name to search 52 * @return the zip code of the given university, or null if no such university. 53 *l 549 public String lookup_by_university(5tring univ) { 55 // COMPLETE this method 56 } 57 } 58

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!