Problem

Create a data type Location that represents a location on Earth using latitudes and longit...

Create a data type Location that represents a location on Earth using latitudes and longitudes. Include a method distanceTo() that computes distances using the great-circle distance (see EXERCISE 1.2.33).

EXERCISE 1.2.33

Great circle. Write a program GreatCircle that takes four double command-line arguments—x1, y1, x2, and y2—(the latitude and longitude, in degrees, of two points on the earth) and prints the great-circle distance between them. The great-circle distance (in nautical miles) is given by the following equation:

d = 60 arccos(sin(x1) sin(x2) + cos(x1) cos(x2) cos(y1y2))

Note that this equation uses degrees, whereas Java’s trigonometric functions use radians. Use Math.toRadi ans() and Math.toDegrees() to convert between the two. Use your program to compute the great-circle distance between Paris (48.87° N and −2.33° W) and San Francisco (37.8° N and 122.4° W).

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 3.2