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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:00
Which of the following is not contained on the slide show toolbar? a. next button b. slide button c. close button d. pen too
Answers: 2
question
Computers and Technology, 23.06.2019 01:10
Are special combinations of keys that tell a computer to perform a command. keypads multi-keys combinations shortcuts
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Plz ( which is an example of a good url?
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
Hazel has just finished adding pictures to her holiday newsletter. she decides to crop an image. what is cropping an image?
Answers: 1
You know the right answer?
In this exercise you will write a program to compute the distance between any two geo locations. In...
Questions
question
English, 06.11.2020 21:40
question
Mathematics, 06.11.2020 21:40
question
Mathematics, 06.11.2020 21:40
question
Health, 06.11.2020 21:40
question
Mathematics, 06.11.2020 21:40
question
Mathematics, 06.11.2020 21:40
Questions on the website: 13722360