The great circle distance is the distance between two points on the surface of a sphere. Let (x 1 , y 1 ) and (x 2 , y 2 ) be the geographical latitude and longitude of two points. The great circle distance between the two points can be computed using the following formula: ?d = radius * arccos(sin(x 1

Chapter 4, Programming Exercises #2

This problem has been solved!


Do you need an answer to a question different from the above? Ask your question!

The great circle distance is the distance between two points on the surface of a sphere. Let (x1, y1) and (x2, y2) be the geographical latitude and longitude of two points. The great circle distance between the two points can be computed using the following formula:

?d = radius * arccos(sin(x1) * sin(x2) + cos(x1) * cos(x2) * cos(y1 - y2))

Write a program that prompts the user to enter the latitude and longitude of two points on the earth in degrees and displays its great circle distance. The average earth radius is 6,371.01 km. Note that you need to convert the degrees into radians using the Math.toRadians method since the Java trigonometric methods use radians. The latitude and longitude degrees in the formula are for north and west.

?Use negative to indicate south and east degrees. Here is a sample run:

image

Related Book For answer-question

Introduction to Java Programming, Comprehensive Version

10th Edition

Authors: Y. Daniel Liang

ISBN: 978-0133761313