**THIS IS A JAVA PROBLEM, NEEDS TO BE DONE WITH ECLIPSE!** 1 java file, Apendix a,b,c are given. Complete the program that shows (i) zip codes given a city and (ii) city given a zip code at the URL...

**THIS IS A JAVA PROBLEM, NEEDS TO BE DONE WITH ECLIPSE!** 1 java file, Apendix a,b,c are given. Complete the program that shows (i) zip codes given a city and (ii) city given a zip code at the URL http://www.melissadata.com/lookups/zipcityphone.asp. In the web site: (1) When you enter a zip code, the URL returns a page with information about the zip code (city, state, population, and number of business, etc. in the zip code). For example, if you enter 50011, the returned page is http://www.melissadata.com/lookups/ZipCityPhone.asp?InData=50011 and you can check the corresponding city is Ames, IA. (2) When you enter a city name (and a state name), the URL returns a page with information about the city (list of zip codes, are codes, etc.). For example, if you enter “Ames IA”, the return page is http://www.melissadata.com/lookups/ZipCityPhone.asp?InData=ames+ia and you can check the list of zip codes and area codes in Ames, IA. In the program, use the menu of ZipLookup.java . In other words, ask the user to select (i) lookup by zip, (ii) by city, (iii) or quit. You can assume user will give five digits for lookup by zip code, and city and state (abbreviated) names for lookup by city. Unlike Homework 6, your program should list all zip codes for lookup by city. After user selects a menu, send the request to the server using the URLConnection. Get the information needed from the HTML in the web page. In Appendices A and B at the end of this document, screenshot and sample HTML codes are attached for lookup by zip (Appendix A) and lookup by city (Appendix B). In Appendix C, a sample run of the program is attached. Use the provided Incomplete source code ( ZipLookupWeb.java ) as a starting point. In modifying the source file,1. Do not change the file (class) names and method names. Points will be deducted if you have different names. 2. Fill in your name in the @author section of the comment in each of the files. If you do not, points will be deducted. Submit your work to Canvas. Make sure to submit source file (*.java). Class file (*.class) will not be graded and receive zero credit. ZipLookup.java file -------------------------------------------------------------------------------------------------------------------------------------------------------- . . . */ public class ZipLookup { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); System.out.println("Enter the name of the zipcode file: "); String fileName = in.nextLine(); LookupTable table = new LookupTable(); FileReader reader = new FileReader(fileName); table.read(new Scanner(reader)); boolean more = true; while (more) { System.out.println("Lookup Z)ip, C)ity name, Q)uit?"); String cmd = in.nextLine(); if (cmd.equalsIgnoreCase("Q")) more = false; else if (cmd.equalsIgnoreCase("Z")) { System.out.println("Enter Zipcode:"); String n = in.nextLine(); System.out.println("City name: " + table.lookup(n) + "\n"); } else if (cmd.equalsIgnoreCase("C")) { System.out.println("Enter city name:"); String n = in.nextLine(); System.out.println("Zip code: " + table.reverseLookup(n)+ "\n"); } } } } -------------------------------------------------------------------------------------------------------------------------------------------------------- ZipLookup.java file -------------------------------------------------------------------------------------------------------------------------------------------------------- import java.util.Scanner; import java.io.InputStream; import java.io.IOException; import java.net.URL; import java.net.URLConnection; /** * Code for HW7 * @author */ /** This program provides lookups by city and zip code */ public class ZipLookupWeb { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); boolean more = true; while (more){ System.out.println("Lookup Z)ip, C)ity name, Q)uit?"); String cmd = in.nextLine(); if (cmd.equalsIgnoreCase("Q")){ more = false; }else if (cmd.equalsIgnoreCase("Z")){ System.out.println("Enter Zipcode:"); String n = in.nextLine(); String pageurl = ... URL u = new URL(pageurl); URLConnection connection = u.openConnection(); InputStream inStream = connection.getInputStream(); Scanner ins = new Scanner(inStream); String statename = ""; String cityname = ""; // read each line, detect if the line contains city name or state name, // extract and store the information while (...){ ... } System.out.println(cityname + ", " + statename); ins.close(); }else if (cmd.equalsIgnoreCase("C")){ System.out.println("Enter city name:"); String ct = in.nextLine(); System.out.println("Enter State name:"); String st = in.nextLine(); String pageurl = ... URL u = new URL(pageurl); URLConnection connection = u.openConnection(); InputStream inStream = connection.getInputStream(); Scanner ins = new Scanner(inStream); // read each line, detect if the line contains zip code, // extract zip code and print while (...) { ... } ins.close(); } } // end while in.close(); } } -------------------------------------------------------------------------------------------------------------------------------------------------------- APPENDICES Appendix A: Screenshot and HTML file for lookup by zip code (50011) Results for ZIP Code 50011 Map of ZIP Code Campaign Contributors Carrier Routes Climate Averages Nearest Mailing House NonProfits Public Schools Street Names State Iowa (IA) Type of ZIP Code Unique ZIP assigned to IOWA STATE UNIVERSITY USPS Preferred City Name AMES Other City Name (Not Recommended)IOWA STATE UNIVERSITY Businesses in ZIP 148 Click here for list Population (2010) of ZIP 1,390 USPS Residential Deliveries in ZIP 0 USPS Business Deliveries in ZIP 1 USPS Apartment Deliveries in ZIP 0 USPS PO Box Deliveries in ZIP 0 Area Code 515 Time Zone (Local Time) Central ( 10/9/2017 12:44:04 AM ) County Name (FIPS) County Seat STORY (19169 ) 100.0% Addresses in County Economy Appendix B: Screenshot and HTML file for lookup by city (Ames IA) Cities Matching Ames Ia City NameStateZIP CodeTypeArea CodeCounty Click for Map AmesIowa50010 515Story AmesIowa50011U href="ZipCityPhone.asp?AreaCode=515">515Story AmesIowa50012U515Story AmesIowa50013U515Story AmesIowa50014 515Story
May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here