subject

In this exercise you will write a program to compute the distance between any two geo locations. In this program you will ask the user for four numbers. starting latitude starting longitude ending latitude ending longitude Then, using the GeoLocation class, compute the distance in miles between the two locations. A sample program run should match exactly as below: 1. starting latitude
2. starting longitude
3. ending latitude
4. ending longitude Doub
Then, using the GeoLocation class, compute the distance in miles between the two locations.
A sample program run should match exactly as below:
Enter the latitude of the starting location: 18.8567 Fara
Enter the longitude of the starting location: 23598
Enter the latitude of the ending location: 53 5872 dist
Enter the longitude of the ending location: 21275
The distance is 280 28639358788545 miles.
How Far Away is ...?
1
2 This class stores information about a location on Earth. Locations are
3 specified using latitude and longitude. The class includes a method for
4 computing the distance between two locations.
5 *
6 This implementation is based off of the example from Stuart Reges at
7 the University of Washington.
8 */
9
10 public class Geolocation
11
12 // Earth radius in miles
13 public static final double RADIUS - 3963.1676;
14
15 private double latitude;
16 private double longitude;
17
18 /** 20 21 22 23
19 /* constructs a geo location object with given latitude and longitude
20 */
21 public GeoLocation(double theLatitude, double theLongitude)
22 {
23 latitude - thelatitude;
24 longitude = theLongitude:
25 }
26
27 */
28 Returns the latitude of this geo location
29 */
30 public double getLatitude
31 {
32 return latitude;
33 )
34
35 /**
36 * returns the longitude of this geo location
37 */
38 public double getLongitude()
39 {
40 return longitude;
41 }
42
43 // returns a string representation of this geo location
44 public String tostring()
45 {
46 return "latitude: " + latitude + " longitude: "longitude;
47
48
49 // returns the distance in miles between this geo location and the given
50 other geo location
51 public double distanceFron(Geolocation other)
52
53 double lati = Math. toRadians(latitude);
54 double longi - Math. to Radians(longitude):
55 double lat2 = Math. toRadians (other. latitude);
How Far Away is ...?
1 import java. util. Scanner;
2
3 public class HowFar Away
4
5 public static void main(String[] args)
6 {
7 // your code here.
8 Scanner scanner = new Scanner(System. in);
9 System. out. println("Enter the latitude of the starting location: ");
10 double myDouble = scanner. nextDouble(); 1
11 System. out. println("Enter the longitude of the starting location: ");
12 double lo scanner. nextDouble();
13 System. out. println("Enter the latitude of the endeing location: ");
14 double la = scanner. nextDouble();
15 system. out. println("Enter the longitude of the ending location: "); 5
16 double end scanner. nextDouble();
17 double di; HowFar Away the = new HowFarAway();
18 di distanceFrom();
19 System. out. println("The distance is" + di + "miles");
20 System. out. print In(d1); } }

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 04:20, RandomLollipop
Which network media uses different regions of the electromagnetic spectrum to transmit signals through air? uses different regions of the electromagnetic spectrum to transmit signals through air.
Answers: 2
image
Computers and Technology, 23.06.2019 15:00, med69
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a. an advanced knowledge of physics and math b. an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 2
image
Computers and Technology, 23.06.2019 15:00, hunteryolanda82
Based on the current economic situation do you expect the employment demand for graduating engineers to increase or decrease? explain the basis for your answer. with a significant economic recovery, what do you think will happen to future enrollments in graduating engineering programs?
Answers: 1
image
Computers and Technology, 23.06.2019 20:00, shadow6728g
How much current flows through the alternator brushes? a. 2–5 a b. 25–35 a, depending on the vehicle c. 5–10 a d. 10–15 a
Answers: 2
You know the right answer?
In this exercise you will write a program to compute the distance between any two geo locations. In...

Questions in other subjects:

Konu
Mathematics, 07.04.2021 05:30
Konu
Mathematics, 07.04.2021 05:30
Konu
Mathematics, 07.04.2021 05:30
Konu
Social Studies, 07.04.2021 05:30
Konu
Mathematics, 07.04.2021 05:30
Konu
Mathematics, 07.04.2021 05:30