5. Write a program that computes the spherical distance between two points on the surface of the Earth, given their latitudes and longitudes. This is a useful operation because it tells you how far apart two cities are if you multiply the distance by the radius of the Earth, which is roughly 6372.795 km. Let v1, A1, and 42, d2 be the latitude and longitude of two points, respectively. AX, the longitudinal difference, and AO, the angular difference/distance in radians, can be determined as follows from the spherical law of cosines: Ao = arccos(sing¡sino2 + cosY2cosY>COs AX) For example, consider the latitude and longitude of two major cities: • Nashville, TN: N 36°7.2/, W 86°40.2/ • Los Angeles, CA: N 33°56.4/, W 118°24.0/ You must convert these coordinates to radians before you can use them effectively in the formula. After conversion, the coordinates become • Nashville: p = 36. 12° = 0.6304 rad, A¡ = -86. 67° = -1.5127 rad • Los Angeles: 2 = 33.94° = 0.5924 rad, A2 = -118. 40° = -2.0665 rad Using these values in the angular distance equation, you get rAo = 6372.795 × 0.45306 = 2887.259 km Thus, the distance between these cities is about 2887 km, or 1794 miles. (Note: To solve this problem, you will need to use the Math.acos method, which returns an arccosine angle in radians.)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
How do you do this? JAVA. Comment everything out. Prompt the user for input and use a scanner object to read the input. Program should read input as decimal degrees and assume that all latitudes and longitudes are positive numbers.
5. Write a program that computes the spherical distance between two points on the surface of the Earth, given their latitudes
and longitudes. This is a useful operation because it tells you how far apart two cities are if you multiply the distance by
the radius of the Earth, which is roughly 6372.795 km.
Let y1, A1, and P2, d2 be the latitude and longitude of two points, respectively. AX, the longitudinal difference, and Ao,
the angular difference/distance in radians, can be determined as follows from the spherical law of cosines:
Ao =
arccos(sing,siný2 + cosy¿cosP2COs AX)
For example, consider the latitude and longitude of two major cities:
• Nashville, TN: N 36°7.2/, W 86°40.2/
· Los Angeles, CA: N 33°56.4/, W 118°24.0/
You must convert these coordinates to radians before you can use them effectively in the formula. After conversion, the
coordinates become
• Nashville: 91 = 36. 12° = 0.6304 rad, A¡ = -86. 67° = –1.5127 rad
· Los Angeles: P2 = 33. 94° = 0.5924 rad, A, = -118.40° = -2.0665 rad
Using these values in the angular distance equation, you get
rAo = 6372.795 × 0.45306 = 2887.259 km
Thus, the distance between these cities is about 2887 km, or 1794 miles. (Note: To solve this problem, you will need to
use the Math.acos method, which returns an arccosine angle in radians.)
Transcribed Image Text:5. Write a program that computes the spherical distance between two points on the surface of the Earth, given their latitudes and longitudes. This is a useful operation because it tells you how far apart two cities are if you multiply the distance by the radius of the Earth, which is roughly 6372.795 km. Let y1, A1, and P2, d2 be the latitude and longitude of two points, respectively. AX, the longitudinal difference, and Ao, the angular difference/distance in radians, can be determined as follows from the spherical law of cosines: Ao = arccos(sing,siný2 + cosy¿cosP2COs AX) For example, consider the latitude and longitude of two major cities: • Nashville, TN: N 36°7.2/, W 86°40.2/ · Los Angeles, CA: N 33°56.4/, W 118°24.0/ You must convert these coordinates to radians before you can use them effectively in the formula. After conversion, the coordinates become • Nashville: 91 = 36. 12° = 0.6304 rad, A¡ = -86. 67° = –1.5127 rad · Los Angeles: P2 = 33. 94° = 0.5924 rad, A, = -118.40° = -2.0665 rad Using these values in the angular distance equation, you get rAo = 6372.795 × 0.45306 = 2887.259 km Thus, the distance between these cities is about 2887 km, or 1794 miles. (Note: To solve this problem, you will need to use the Math.acos method, which returns an arccosine angle in radians.)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education