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 certain kind of fish in the ocean eats only algae. a seal eats this fish a bear eats the seal .when the bear dies,it’s recycle
STatiana [176]

Answer:seal

Explanation:

4 0
2 years ago
Explain what will happen if we continue to use fossil fuels at the rate we are now and what impacts it will have on the planet.
Westkost [7]

Answer:

At the point when non-renewable energy sources are singed, they discharge carbon dioxide and other ozone depleting substances, which thusly trap heat in our air, making them the essential supporters of an Earth-wide temperature boost and environmental change. At the point when we consume oil, coal, and gas, we don't simply meet our vitality needs—we drive the current an unnatural weather change emergency also. Non-renewable energy sources produce huge amounts of carbon dioxide when consumed. Carbon discharges trap heat in the air and lead to environmental change.

7 0
3 years ago
which application software allows you to compose written ideas on a computer? database, spreadsheet, word processor or graphics
Kazeer [188]
Word processor because it's more for writing
8 0
3 years ago
A ____ is an e-mail attack in which the attacker routes large quantities of e-mail to the target system hoping to overwhelm the
GarryVolchara [31]

Answer:

Mail bomb is the correct answer.

Explanation:

In the following statement, A mail bomb is the type of attack on e-mail of the particular person by which the attacker transfers large quantities of e-mail to the target computer in the expectation of flooding the target with so much meaningless e-mail that legitimate e-mail is not accessible. So, that's why the following answer is correct.

3 0
2 years ago
A simple algorithm for handling requests works like this:________ a) all requests users make are stored. b) The elevator priorit
bezimeni [28]

Answer:

b) The elevator prioritizes the requests that are on the way where it’s going, but also based on a first come first served principle.

Explanation:

Elevator routing often looks complex, as the elevator has to decide whether to go to the person who has waited the longest or the one who is closest? There are also issues of how long should the rider spend.

A simple algorithm can be designed where the elevator prioritizes the requests that are on the way where it’s going, but also based on a first come first served principle. Once it exhausts the request in its current direction, it then switches directions if there are requests in that direction. This way the elevator is able to tackle the complex issue based on the simple algorithm.

8 0
3 years ago
Read 2 more answers
Other questions:
  • SecOps focuses on integrating the need for the development team to provide iterative and rapid improvements to system functional
    11·1 answer
  • When you right-click certain areas of the Word or other Office app windows, a command menu will appear. Group of answer choices
    13·1 answer
  • An organization is assigned a Class-C network 200.120.80.0 and wants to form subnets for its threedepartments: D1 (60hosts), D2
    7·1 answer
  • When the program generates or populates reports after getting the data and processinng,it is called
    9·1 answer
  • ​Suppose your computer network was compromised in a large scale virus attack last Thursday. Most of the data files got corrupted
    8·1 answer
  • What technique involves graphical methods and nontechnical language that represent the system at various stages of development a
    14·1 answer
  • What is out put in a computer
    14·2 answers
  • What keyword must be used on any method (function) on your class that is called from your main() method?
    15·1 answer
  • Pro and Cons of Artificial Intelligence in Art <br><br> You must have 3 statements in each
    14·1 answer
  • Write a program that uses an STL List of integers. a. The program will insert two integers, 5 and 6, at the end of the list. Nex
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!