subject

In this problem we are going to use ArrayLists and classes to design a road trip.

You have three classes: GeoLocation. java from earlier, which represents a geo location. A RoadTrip. java class which represents a road trip (or an ordered list of places), and a RoadTripTester. java class which brings them all together.

In GeoLocation. java:

Add a private instance variable called name which is a String. This represents the name of the location.

Modify the Geolocation class constructor so that it is now of the format

public GeoLocation(String name, double theLatitude, double theLongitude)
Add a getter method for name called getName().

Update the toString so that it returns a String of the format

San Francisco (37.7833, -122.4167)
Now, you’ll also need to create a RoadTrip class. The RoadTrip stores an ordered list of locations, so you’ll need to have an ArrayList. You’ll also need to support these methods.

// Create a GeoLocation and add it to the road trip
public void addStop(String name, double latitude, double longitude)

// Get the total number of stops in the trip
public int getNumberOfStops()

// Get the total miles of the trip
public double getTripLength()

// Return a formatted toString of the trip
public String toString()
We’ve given you a tester program to help get you started.

The output from that program would be:

1. San Francisco (37.7833, -122.4167)
2. Los Angeles (34.052235, -118.243683)
3. Las Vegas (36.114647, -115.172813)

Stops: 3
Total Miles: 572.9708850442705
import java. util.*;

public class RoadTrip
{

}

public class GeoLocation
{
// Earth radius in miles
public static final double RADIUS = 3963.1676;

private double latitude;
private double longitude;
private String name;

/**
* Constructs a geo location object with given latitude and longitude
*/
public GeoLocation(String name, double theLatitude, double theLongitude)
{
latitude = theLatitude;
longitude = theLongitude;
}

/**
* Returns the latitude of this geo location
*/
public String getName()
{
return name;
}
public double getLatitude()
{
return latitude;
}

/**
* returns the longitude of this geo location
*/
public double getLongitude()
{
return longitude;
}
public void addStop(String name, double latitude, double longitude)
{

}

// returns a string representation of this geo location
public String toString()
{
return name + "(" + latitude + ", " + longitude + ")";
}

// returns the distance in miles between this geo location and the given
// other geo location
public double distanceFrom(GeoLocation other)
{
double lat1 = Math. toRadians(latitude);
double long1 = Math. toRadians(longitude);
double lat2 = Math. toRadians(other. latitude);
double long2 = Math. toRadians(other. longitude);
// apply the spherical law of cosines with a triangle composed of the
// two locations and the north pole
double theCos = Math. sin(lat1) * Math. sin(lat2) +
Math. cos(lat1) * Math. cos(lat2) * Math. cos(long1 - long2);
double arcLength = Math. acos(theCos);
return arcLength * RADIUS;
}
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:40, ihatemylife0
Least square fit to polynomial write a function leastsquarefit3pol that solves a linear system of equations to find a least squares fit of a third order polynomial to an experimental data set given as two row arrays. the function leastsquarefit3pol must explicitly solve a set of linear equations and cannot use polyfit. there should be no restriction on the size of the problem that can be solved.
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, rowdycar313p0ao5k
[java] create an application called registrar that has the following classes: a. a student class that minimally stores the following data fields for a student: - name - student id number - number of credits - total grade points earned and this class should also be provides the following methods: - a constructor that initializes the name and id fields - a method that returns the student name field - a method that returns the student id field - methods to set and retrieve the total number of credits - methods to set and retrieve the total number of grade points earned. - a method that returns the gpa (grade points divided by credits) b. an instructor class that minimally stores the following data fields for an instructor: - name - faculty id number - department the following methods should be provided: - a constructor that initializes the name and id fields - methods to set and retrieve the instructor’s department. c. a course class that minimally stores the following data for a course: - name of the course- course registration code- maximum number of 35 students- instructor- number of students- students registered in the course (an array)the following methods should also be provided: - a constructor that initializes the name, registration code, and maximum number of students- methods to set and retrieve the instructor- a method to search for a student in the course; the search should be based on an id number.- a method to add a student to the course. if the course is hill, then an exception with an appropriate message should be raised (try creating your own exception class for this). also, be sure that the student is not already registered in the course. the list of students should be in the order that they registered.- a method to remove a student from the course. if the student is not found, then an exception with an appropriate message should be raised (use the same exception class mentioned a method that will allow course objects to be output to a file using object serialization- a method that will allow course objects to be read in from a file created with object serializationyou will note that the student and instructor classes described above have some commonality. create aperson class that captures this commonality and uses it as a base class for student and instructor. this class should be responsible for the name and id fields and also provide atostring method that returns a string of the form name, id. this will be the inheritedtostring method for the student and instructor classes.1. draw a uml diagram for diss application.2. implement the previous classes in java. write a main program that can serve as a test class that tests all of the methods created and demonstrates that they are working
Answers: 2
image
Computers and Technology, 23.06.2019 09:30, jason9394
Facial expressions and gestures are examples of messages.
Answers: 3
image
Computers and Technology, 23.06.2019 13:50, mrfishyyyy
Explain how email technologies enable the exchange of messages between users. find out the typical parts of an email address and explain each part.
Answers: 1
You know the right answer?
In this problem we are going to use ArrayLists and classes to design a road trip.

You ha...

Questions in other subjects: