Question: Chapter 4 Project Project Name: Chpt4_Project Class Name: Chpt4_Project Write a Java program that accepts the coordinates of two cities, and outputs the distance between

Chapter 4 Project

Project Name: Chpt4_Project

Class Name: Chpt4_Project

Write a Java program that accepts the coordinates of two cities, and outputs the distance between them in miles.

Inputs: The names of two cities and their latitudes and longitudes.

Enter the first city:

Enter the second city:

Enter latitude and longitude of first city separated by a space (example 28.8 81.2):

Enter latitude and longitude of second city separated by a space (example 28.8 81.2):

Outputs: The distance between the two cities in miles, note: replace with the distance calculated

The distance between the two cities is miles

Step 1. Create an algorithm (either flowchart or pseudocode) that you will use to write the program. Place the algorithm in a Word document.

Step 2. Code the program in Eclipse to compute and display the distance between the two cities in miles. The distance in miles must be formatted to two decimal places using the printf command.

Note: You can use Google Maps to get lat/long of a city. Start Google Maps and right-click on a city then choose whats here?

The math formula for the distance between two points is:

Chapter 4 Project Project Name: Chpt4_Project Class Name: Chpt4_Project Write a Java

To convert the difference in latitude to miles, multiply by 69

y = (lat1 lat2) * 69;

To convert the difference in longitude to miles, multiply by 55

x = (long1 long2) * 55;

Once you have calculated the x and y values, which are in miles, use this Java formula to calculate distance in miles. Note: Math.sqrt returns a double value.

distance = Math.sqrt(x*x + y*y);

Step 3. Test your program by computing the distance between Orlando and Tampa. The latitudes and longitudes are provided below. Use the Snip It tool in Windows or a similar tool on the Mac to cut and paste the Eclipse Console output window into the same Word document as the algorithm in Step 1.

program that accepts the coordinates of two cities, and outputs the distance

(x2, y2) distance= (x2-x1)2+(y2-y1)2 (xl, y1) difference inlongitude (x) difference inlatitude (y) Problems @ JavadocDeclaration Console 3Data Hierarchy C4 Project [Java Application) C:AProgram FilesUavajre1.8.0 1441binliaww.&oct 18, 2017,3:25:48 PM) Enter the first city: orlando Enter the second city: Tampa Enter latitude and longitude of first city separated ce (example 28.8 81.2): 28.5 -81.4 space (example 28.8 81.2): 27.9 -82.5 he distance between the two cities is 73.31 miles

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!