Question: Please answer the following question using Java Eclipse. Thank you. Your program must look like the sample photo posted. ****The following code must also be

Please answer the following question using Java Eclipse. Thank you.
Your program must look like the sample photo posted.
****The following code must also be used within your work:

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();

}

}

 Please answer the following question using Java Eclipse. Thank you. Your
program must look like the sample photo posted. ****The following code must

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 amestia and you can check the list of zip codes and area codes in Ames, IA. In the program, use the menu of ZipLookup.java from Homework 6. In other words, ask the user to select (i) lookup by zip, (ii) by city, (ii) 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)

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!