Problem Statement Consider two locations, an origin and a destination, on the globe identified by their latitude and longitude. The distance between these two locations can be computed using the Spherical Law of Cosines. In particular, the distance d is d = arccos (sin(2) sin(2) + cos(P1)cas(2) cos(A)) - R where • pa is the latitude of location A, 22 is the latit ude of location B • Ais the difference between location B's langitude and location A's longitude Ris the (average) radius of the earth, 6,371 kilometers Write a program that prompts the user to enter the latitude and longitude of two locations and then computes the distance between them using the above formula. Note that latitude inputs will be in degrees and in the range [-90, 90] and longitude will be in degrees in the range [-180, 180 . Negative values correspond to the westem and southem hemispheres. Hack 2.0 - Computer Science I 1/2
Problem Statement Consider two locations, an origin and a destination, on the globe identified by their latitude and longitude. The distance between these two locations can be computed using the Spherical Law of Cosines. In particular, the distance d is d = arccos (sin(2) sin(2) + cos(P1)cas(2) cos(A)) - R where • pa is the latitude of location A, 22 is the latit ude of location B • Ais the difference between location B's langitude and location A's longitude Ris the (average) radius of the earth, 6,371 kilometers Write a program that prompts the user to enter the latitude and longitude of two locations and then computes the distance between them using the above formula. Note that latitude inputs will be in degrees and in the range [-90, 90] and longitude will be in degrees in the range [-180, 180 . Negative values correspond to the westem and southem hemispheres. Hack 2.0 - Computer Science I 1/2
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
Related questions
Question
![**Problem Statement**
Consider two locations, an origin and a destination, on the globe identified by their latitude and longitude. The distance between these two locations can be computed using the Spherical Law of Cosines. In particular, the distance \( d \) is
\[ d = \arccos(\sin(\varphi_1) \sin(\varphi_2) + \cos(\varphi_1) \cos(\varphi_2) \cos(\Delta)) \cdot R \]
where
- \( \varphi_1 \) is the latitude of location A, \( \varphi_2 \) is the latitude of location B
- \( \Delta \) is the difference between location B’s longitude and location A’s longitude
- \( R \) is the (average) radius of the earth, 6,371 kilometers
Write a program that prompts the user to enter the latitude and longitude of two locations and then computes the distance between them using the above formula. Note that latitude inputs will be in degrees and in the range \([-90, 90]\) and longitude will be in degrees in the range \([-180, 180]\). Negative values correspond to the western and southern hemispheres.
---
*Hack 2.0 – Computer Science I* *1 / 2*](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2cd221fc-d452-4e3a-bfa6-1ce3395ee0fb%2Fa4f53a0a-85cb-403a-93e5-ef1800c47641%2Fbyws9w_processed.png&w=3840&q=75)
Transcribed Image Text:**Problem Statement**
Consider two locations, an origin and a destination, on the globe identified by their latitude and longitude. The distance between these two locations can be computed using the Spherical Law of Cosines. In particular, the distance \( d \) is
\[ d = \arccos(\sin(\varphi_1) \sin(\varphi_2) + \cos(\varphi_1) \cos(\varphi_2) \cos(\Delta)) \cdot R \]
where
- \( \varphi_1 \) is the latitude of location A, \( \varphi_2 \) is the latitude of location B
- \( \Delta \) is the difference between location B’s longitude and location A’s longitude
- \( R \) is the (average) radius of the earth, 6,371 kilometers
Write a program that prompts the user to enter the latitude and longitude of two locations and then computes the distance between them using the above formula. Note that latitude inputs will be in degrees and in the range \([-90, 90]\) and longitude will be in degrees in the range \([-180, 180]\). Negative values correspond to the western and southern hemispheres.
---
*Hack 2.0 – Computer Science I* *1 / 2*
![The page provides instructions for calculating air distance based on latitude and longitude, which need to be measured in radians. To convert degrees to radians, use the formula:
\[
r = \frac{deg}{180} \cdot \pi
\]
**Output Example**
Your output should look like this:
```
Location Distance
==================
Origin: (41.948300, -87.655600)
Destination: (40.820600, -96.705600)
Air distance is 764.990931 kms
```
**Instructions**
- **Collaboration**: Collaborate with any number of students during your hack session.
- **Design Test Cases**: Create at least 3 test cases before programming to ensure correctness.
- **Include Names**: Add the names of collaborators in the source file's header.
- **Program Naming**: Name your program `airDistance.c` and submit via webhandin, ensuring correct execution. Each student submits their own copy for individual grading.
- **RTM (Read The Manual)**: Consult the math library manual to understand useful functions.
- **Compiler/System Configuration**: You might need to use the `-lm` flag to link the math library:
```bash
gcc -lm airDistance.c
```
Or on certain systems (e.g., ubuntu/CS50):
```bash
gcc airDistance.c -lm
```](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2cd221fc-d452-4e3a-bfa6-1ce3395ee0fb%2Fa4f53a0a-85cb-403a-93e5-ef1800c47641%2F790tawr_processed.png&w=3840&q=75)
Transcribed Image Text:The page provides instructions for calculating air distance based on latitude and longitude, which need to be measured in radians. To convert degrees to radians, use the formula:
\[
r = \frac{deg}{180} \cdot \pi
\]
**Output Example**
Your output should look like this:
```
Location Distance
==================
Origin: (41.948300, -87.655600)
Destination: (40.820600, -96.705600)
Air distance is 764.990931 kms
```
**Instructions**
- **Collaboration**: Collaborate with any number of students during your hack session.
- **Design Test Cases**: Create at least 3 test cases before programming to ensure correctness.
- **Include Names**: Add the names of collaborators in the source file's header.
- **Program Naming**: Name your program `airDistance.c` and submit via webhandin, ensuring correct execution. Each student submits their own copy for individual grading.
- **RTM (Read The Manual)**: Consult the math library manual to understand useful functions.
- **Compiler/System Configuration**: You might need to use the `-lm` flag to link the math library:
```bash
gcc -lm airDistance.c
```
Or on certain systems (e.g., ubuntu/CS50):
```bash
gcc airDistance.c -lm
```
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images

Knowledge Booster
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.Recommended textbooks for you

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education