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
What is the name given a technological program that typically copies itself and moves through a computer system in order to disr
goldfiish [28.3K]

Answer:

Class of software called "malware"

Explanation:

Some features of malware software:

  • Viruses, worms, Trojans and bots are malware.
  •  Malware is the abbreviation for "malicious software" (malicious code).
  •  Specifically designed to damage, interrupt, illegally steal data from a network.
  • A Trojan it is  software that looks legitimate. Users are typically tricked into loading and executing it on their systems.  

7 0
2 years ago
Which of the following choices is not a viewing option?
malfutka [58]
B. FILE PAGES 
I answered wrong the first time, but according to an exam the answer is B. Definitely trust an exam answer! 
7 0
3 years ago
Live footage refers to:
QveST [7]

Answer:

D

Explanation:

live refers to happening right now and footage refers to videos taken and captured.

8 0
1 year ago
Who likes sandshrew ​
zvonat [6]

Answer:

sandshrew is a cute character in pokemon

6 0
3 years ago
Type of media that uses laser technology to store data and programs is
olganol [36]
The answer is compact disc or cd, only device that use lasers (that arent proprietary floppys) 
8 0
3 years ago
Other questions:
  • If you want to use your computer for recording your band, you would benefit most from a(n)
    13·2 answers
  • during zach's second visit of the year, he incurred a $450 bill. Describe how much is paid by Zach and the insurance carrier
    7·1 answer
  • Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less
    6·2 answers
  • How much does a dodge tomohawk cost for a used one?
    7·1 answer
  • Although your project has been accepted by the customer, the contract with the system vendor specifies that it will support the
    13·1 answer
  • Alvin has created a non-extensive site map of all the commonly visited pages of his website. What is such a site map called?
    13·1 answer
  • The people on this platform are unbelievably nice. its almost rare to see this type of kindness online these days. Just wanted t
    14·1 answer
  • What is the role of computer in education sector?​
    13·1 answer
  • Ginny faced an application error while executing the recorder in opera. Which web browser is generally recommended to use with r
    5·1 answer
  • Edit the program provided so that it receives a series of numbers from the user and allows the user to press the enter key to in
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!