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
Briefly explain what is net neutrality and why is it important today
ICE Princess25 [194]

Net neutrality also means that ISPs can't charge users access fees for particular websites. ... The goal of net neutrality is to ensure that businesses can compete freely on the internet without having to pay gatekeeper tolls. Without it consumers would look more like advertising segments than an open marketplace.

Credits: thestreet.com

6 0
2 years ago
The retention of encoded information over time is called storage. A measure of memory storage that involves identifying informat
Anni [7]

Answer: ask google and search quizlet by it , it will show you

Explanation:

7 0
3 years ago
Write a program that prompts the user to enter a date, using integer values for the month, day, and year, and then prints out th
attashe74 [19]

Answer:

import datetime

user = input("Enter date in yyyy,m,d: ").split(",")

int_date = tuple([int(x) for x in user])

year, month, day =int_date

mydate = datetime.datetime(year, month, day)

print(mydate)

x = mydate.strftime("%B %d, %Y was a %A")

print(x)

Explanation:

The datetime python module is used to create date and time objects which makes it easy working with date-time values. The user input is converted to a tuple of integer items, then they are converted to date time objects and parsed to string with the strftime method.

5 0
2 years ago
Search the link <br><br> gKuJXd3zYDc<br><br> Subscribe I have a vid premiering soon
lawyer [7]
I will hope this helps :p
5 0
2 years ago
A file manager is used for all of the following except ____. A. to move files and folders B. to reorder files and folders C. to
Alex73 [517]

Answer:

A .to move files and folders

5 0
3 years ago
Read 2 more answers
Other questions:
  • False when you tap or click the ‘decrease font size’ button, excel assigns the next lowest font size in the font size gallery to
    13·1 answer
  • Why is it important to save a print copy of electronic sources
    5·1 answer
  • Study and compare the tables and draw conclusions.
    13·1 answer
  • Who invented the speaker?
    14·2 answers
  • What is the point of brainy when other people have to answer your questions but not the cumputer
    9·1 answer
  • Use the drop-down menus to complete the statements about message marking, categorizing, and flagging.
    13·2 answers
  • Find different between manocots and dicots clarify with example​
    14·1 answer
  • Which of the following is a property of TCP?
    8·1 answer
  • Does anybody play nba2k21 On ps4
    8·2 answers
  • What do you think that the next version of IR (IR 5.0) will bring if it was discovered in near future? (hint:- advance IR 4.0 fe
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!