Question: **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

**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

--------------------------------------------------------------------------------------------------------------------------------------------------------

import java.io.IOException; import java.io.FileReader; 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 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) + " "); } else if (cmd.equalsIgnoreCase("C")) { System.out.println("Enter city name:"); String n = in.nextLine(); System.out.println("Zip code: " + table.reverseLookup(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)**THIS IS A JAVA PROBLEM, NEEDS TO BE DONE WITH ECLIPSE!** 1

Appendix B: Screenshot and HTML file for lookup by city (Ames IA)

java file, Apendix a,b,c are given. Complete the program that shows (i)

Results for ZIP Code 50011
Map of ZIP Code Campaign Contributors Carrier Routes Climate Averages Nearest Mailing House NonProfits Public Schools Street Names
StateIowa (IA) Type of ZIP CodeUnique ZIP assigned to IOWA STATE UNIVERSITY USPS Preferred City NameAMES Other City Name (Not Recommended)IOWA STATE UNIVERSITY Businesses in ZIP148 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 Code515 Time Zone (Local Time)Central ( 10/9/2017 12:44:04 AM ) County Name (FIPS) County SeatSTORY (19169 ) 100.0% Addresses in County Economy
ZIP Code Types: P=PO BoxU=Unique M=Military

Appendix C: Sample run of the program Lookup Z)ip, C)ity name, Q)uit? Z Enter Zipcode: 50306 DES MOINES, Iowa Lookup Z)ip, C)ity name, Q)uit? C Enter city name: Ankeny Enter State name: IA 50021 50023 Lookup Z)ip, C)ity name, Q)uit? Q

Thank you. Please make sure to use apendix a,b,c and 2 java files (ZipLookup.java, ZipLookupWeb.java).

Results for ZIP Code 50011 ar mate State lowa (IA) Type of ZIP Code USPS Preferred City Name Other City Name (Not Recommended Businesses in ZIP Population (2010) of ZIP Unique ZIP assigned to IOWA STATE UNIVERSITY AMES IOWA STATE UNIVERSITY 148 Click here for list 1,390 USPS Residential Deliveries in ZIPo 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:50:19 AM) County N STORY (19169 ) 100.0% Addresses in County Economy County Seat
Cities Matching Ames Ia
City NameStateZIP CodeTypeArea CodeCountyClick for Map AmesIowa50010 515Story AmesIowa50011U515Story AmesIowa50012U515Story AmesIowa50013U515Story AmesIowa50014 515Story

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 Databases Questions!