1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
posledela
3 years ago
5

Write a program to calculate the great circle distance between two points on the surface of a sphere. If p1(x1, y1) and p2(x2,y2

) are geographic latitude and longitude of two points, the great circle distance can be computed as
Computers and Technology
1 answer:
Tamiku [17]3 years ago
8 0

Answer:

import java.lang.*;

public class distance { public static double distance(double latitude1,

                                     double latitude2, double longitude1,

                                     double longitude2)

       {

      // Convert Latitude and Longitude to Radians

           longitude1 = Math.toRadians(longitude1);

           longitude2 = Math.toRadians(longitude2);

           latitude1 = Math.toRadians(latitude1);

           latitude2 = Math.toRadians(latitude2);

           

           double d_longitude = longitude2 - longitude1;

           double d_latitude = latitude2 - latitude1;

           double a = Math.pow(Math.sin(d_latitude / 2), 2)

                   + Math.cos(latitude1) * Math.cos(latitude2)

                   * Math.pow(Math.sin(d_longitude / 2),2);

           double val = 2 * Math.asin(Math.sqrt(a));

           // Radius of earth in kilometers is 6371

           double earth_radius = 6371;

           // Calculate and return the distance

           return(val * earth_radius);

       }

       // Main Method

       public static void main(String[] args)

       {

           double latitude1 = 67.32055555555556;

           double latitude2 = 83.31861111111111;

           double longitude1 = -1.7217899;

           double longitude2 = -1.6567799;

           System.out.println(distance(latitude1, latitude2,

                   longitude1, longitude2) + " K.M");

       }

   }

Explanation:

This program is implemented in Java programming language

The formula for the shortest distance between two points on the earth is:

Distance = 3963.0 * arccos[(sin(lat1) * sin(lat2)) + cos(lat1) * cos(lat2) * cos(long2 – long1)]

The latitude and longitude of the two points must be known

The latitude and longitude are converted into radians using built in methods in java.

Take value for the radius of the earth in Kilometers  6371;

Note that a seperate method has been created to calculate the distance

In the driver method (main), values for latitude and logitudes for both places have been hard-corded, then the method distance is called and passed those values

Note also that the distance has been calculated in Kilometers

You might be interested in
A program that will ring a bell six times is what kind of program?
amm1812

Answer:

D

Explanation:

because it is a sequence it does more than one thing

6 0
3 years ago
Read 2 more answers
What is the average time a caller waits for an operator to answer?
kaheart [24]
3-4 minutes is about right is say
7 0
3 years ago
How much cell phone data does the average person use a month
azamat
It all depends on what you're doing online.
7 0
3 years ago
Using the following table as your starting point for each algorithm SJN Given the following information: Job: A B C D E Arrival
victus00 [196]

Answer:

Please check the attachment,

The average turnaround time is 4.8 and average waiting time is 1.

Please note: Exit time is same as completion time.

Explanation:

Please check the attachment.

7 0
3 years ago
If you have created a document that contains a table that is 10 inches wide and 4 inches high, you will want to print the docume
Papessa [141]
True you will want to print the document in Landscape orientation
6 0
3 years ago
Read 2 more answers
Other questions:
  • You have an insurance policy with a $300 premium and a $500 deductible. How much should you expect to pay the insurance company
    15·1 answer
  • Explain how being a metal, metalloid, or non-metal affects conductivity
    10·1 answer
  • The jailbreak property that, if the user turns the device off and back on, the device will start up completely, and the kernel w
    15·1 answer
  • What is the duty of business to contribute to the well-being of society
    12·1 answer
  • The Cursor is blinking in a white area on the Screen. This area where text will appear in the ____.
    10·2 answers
  • Search engines use indexes created by web _________ to provide fast searches.
    7·1 answer
  • (Reverse number) Write a program that prompts the user to enter a four-digit inte- ger and displays the number in reverse order.
    9·1 answer
  • Describe the main roles of the communication layer, the network-wide state-management layer, and the network-control application
    15·1 answer
  • In Python write a program that reads a list of integers into a list as long as the integers are greater than zero, then outputs
    8·1 answer
  • even if we reach that state where an AI can behave as human does,how do we measure if AI is acting like a human?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!