Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please answer the following with code below in Java: In this part of the lab you will write client code to manipulate some GeoLocation objects.
Please answer the following with code below in Java: In this part of the lab you will write client code to manipulate some GeoLocation objects. The GeoLocation class is being provided to you, so you don't have to write it You will instead be writing code that constructs and manipulates three GeoLocation objects.
The popular TV series Breaking Bad made use of geographic location information. The Walter White character buried millions of dollars at a particular location in the desert outside of Albuquerque, New Mexico. He then bought a lottery ticket to help him remember that his stash was buried at a latitude of degrees, minutes, seconds and a longitude of degrees, minutes, seconds. Your client program will compute the distance between Walter's stash and the local FBI building and a local studio known as ABQ Studios where Breaking Bad was filmed
Your program should produce the following output:
The stash is at latitude: longitude:
ABQ studio is at latitude: longitude:
FBI building is at latitude: longitude:
Distance in miles between:
stashstudio
stashfbi
Instructions:
Create a new Java class in NetBeans called GeoLocationClient. This class is a main class and should have a main method.
Create three GeoLocation objects with the values you see in the output above.
Print the three objects and call the distanceFrom method twice to get the desired output. Please note that the latitudelongitude information in the first three lines of output should be produced by calls to the GeoLocation's toString method, and the values in the final two lines of output should be produced by calls to the GeoLocation's distanceFrom method. code: package cisgeolocation;
public class GeoLocation
public static final double RADIUS ; Earth radius in miles
private double latitude;
private double longitude;
constructs a geo location object with given latitude and longitude
public GeoLocationdouble inLatitude, double inLongitude
latitude inLatitude;
longitude inLongitude;
returns the latitude of this geo location
public double getLatitude
return latitude;
returns the longitude of this geo location
public double getLongitude
return longitude;
returns a string representation of this geo location
@Override
public String toString
return "latitude: latitude longitude: longitude;
returns the distance in miles between this geo location and the given
other geo location
public double distanceFromGeoLocation other
double lat Math.toRadianslatitude;
double long Math.toRadianslongitude;
double lat Math.toRadiansotherlatitude;
double long Math.toRadiansotherlongitude;
apply the spherical law of cosines with a triangle composed of the
two locations and the north pole
double theCos Math.sinlat Math.sinlat Math.coslat Math.coslat Math.coslong long;
double arcLength Math.acostheCos;
double distance arcLength RADIUS;
return distance;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started