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
You are an inventor. You are taking out an ad in a newspaper because you want people to buy/use your product/invention. Include
goldenfox [79]
The light bulb is important because it helps you see in the dark.

The light bulb is a round object that produces light from energy.

People can't live without the light bulb because it helps you out a lot such as see in the dark like when you do homework at night.

It could help businesses profit because many will want to buy it cause they can be cheap but many will sell and it could help you a lot!
4 0
3 years ago
________is one color shade gradually progressing to another shade of the same color or one color progressing to another color.
posledela

Answer:

Gradient fill

Explanation:

A gradient fill is a visual effect that makes a three dimensional color look by mixing one color shade gradually progressing to another shade of the same color or one color progressing to another color. for example a dark red progressively changing to light red or red progressively changing to blue.

8 0
3 years ago
Selecting the Tiled windows arrangement option places the windows in a(n) _______ pattern on the screen.
Archy [21]

Answer:

Selecting the Tiled windows arrangement option places the windows in a(n) Grid pattern on the screen.

Explanation:

3 0
2 years ago
What is the type of data in the list [103, 405, 527, 396, 503]?
Mariulka [41]

Answer:

alphanumeric.........

3 0
2 years ago
Read 2 more answers
Write a pyhton program to calculate area of a circle?
marta [7]

Answer:

The code to calculate the area of a circle is:

from math import pi

def circleArea(radius):

 if radius > 0:

   return pi * (radius ** 2)

 else:

   return None

if __name__ == '__main__':

 radius = 5

 print("Radius: {} Area: {}".format(radius,circleArea(radius)))

Explanation:

A detailed explanation of each line of code is given below.

#Define the number pi used to calculate the area

from math import pi

#We define a function that calculates the area of a circle

def circleArea(radius):

#Check if the radius is valid ( radius > 0) since there aren´t negative radius

 if radius > 0:

#Compute the area formula for a circle \pi * radius^{2}

   return pi * (radius ** 2)

 else:

#Return None if the radius is invalid

   return None

#Run the function we´ve defined

if __name__ == '__main__':

#Define a radius

 radius = 5

#Call the function and parse the radius through it, then print the result

 print("Radius: {} Area: {}".format(radius,circleArea(radius)))

8 0
3 years ago
Other questions:
  • Carlos owns a hardware store. He currently is not using any software to track what he has in the store. In one to two sentences,
    9·2 answers
  • Todd, a travel agent, lost his job due to no need for his skill. This is an example of what type of unemployment?
    12·1 answer
  • Energy is defined as stored energy
    13·2 answers
  • What term is used to refer to the way companies collect and process data in order to create new information to make important bu
    13·1 answer
  • Use a switch statement to display "one" if the user has entered 1, "two" if the user has entered 2, and "three" if the user has
    14·1 answer
  • When Adobe Photoshop was released for the first time? A: 1984 B: 1990 C: 1991 D: 1992
    8·1 answer
  • Create the following SQL Server queries that access the Northwind database. Place them in a zip file and place the zip file in t
    6·1 answer
  • You are working on a graphical app, which includes multiple different shapes. The given code declares a base Shape class with an
    15·1 answer
  • Which type of software is used for marketing research as a way to find out about users' preferences?
    12·1 answer
  • How each programming language differs in terms of constructs, techniques, use and requirements?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!