Computers and Technology

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); } }

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 06:00, willowcollins3753
Write a program that uses a widgetviewer object to do the following: generate two random integers between 1 and 9 (inclusive). name one of them x, the other y. display them to the user using jlabel objects. create a jlabel object displaying the text "enter an operation number." create a jtextfield for the user's input. create a jbutton displaying the text "press here when you've entered your operation." use addandwait to add it to the widgetviewer object. when the user clicks the jbutton, evaluate operation in the following order to determine the one and only mathematical operation to perform on x and y. use a jlabel to display the result. if operation is between 1 and 10 inclusive, add x and y. if operation is evenly divisible by 4, subtract y from x. if operation is evenly divisible by 5, use integer division to divide y into x. if operation is an even number, use floating point division to divide y into x. if none of the other tests on operation apply, multiply x and y. note: operation can be negative or zero.
Answers: 2
image
Computers and Technology, 22.06.2019 11:30, jcazares3558
Awell-diversified portfolio needs about 20-25 stocks from different categories.
Answers: 2
image
Computers and Technology, 22.06.2019 18:00, alyssacyamamoto8050
Budgets you to do all of the following expect a) send frivolously b) avoid over spending c) gain financial independence d) examine your priorities and goals
Answers: 2
image
Computers and Technology, 22.06.2019 19:20, SundaeSunday
Consider the following code snippet: #ifndef cashregister_h#define cashregister_hconst double max_balance = 6000000.0; class cashregister{public: cashregister(); cashregister(double new_balance); void set_balance(double new_balance); double get_balance() const; private: double balance[12]; }; double get_monthly_balance(cashregister bk, int month); #endifwhich of the following is correct? a)the header file is correct as given. b)the definition of max_balance should be removed since header files should not contain constants. c)the definition of cashregister should be removed since header files should not contain class definitions. d)the body of the get_monthly_balance function should be added to the header file.
Answers: 1
Do you know the correct answer?
In this exercise you will write a program to compute the distance between any two geo locations. In...

Questions in other subjects:

Konu
Geography, 20.10.2020 16:01
Konu
Mathematics, 20.10.2020 16:01