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 02:00
Aisha has finished working on a word processing document that contains 15 pages. she has added some special elements in the first three pages, page 9 and 10, and page 15 from the document. she wants to print only these pages to see how they look. which option is the correct way to represent (in the print dialog box) the pages that aisha wants to print?
Answers: 3
question
Computers and Technology, 23.06.2019 09:00
What provides an array of buttons for quick access to commonly used commands and tools
Answers: 1
question
Computers and Technology, 23.06.2019 21:20
In microsoft word, when you highlight existing text you want to replace, you're in              a.  advanced mode.    b.  automatic mode.    c.  basic mode.    d.  typeover mode
Answers: 1
question
Computers and Technology, 23.06.2019 23:00
How do you know if the website is secure if you make a purchase
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
question
Health, 04.03.2021 22:40
Questions on the website: 13722367