BCC Java Question
Description
Ask the user to input four pairs of x,y coordinates in this format:
x0 y0 x1 y1 x2 y2 x3 y3
Use the SimplePoint class below and add a main() method to it. The main() method should create a SimplePoint object for each pair of x,y coordinates. Next, it should determine which of the four points is furthest from point 0,0. Finally, the main() method should output the x,y coordinates of the furthest point, along with the distance. Match the sample run below.
Here is the SimplePoint class:
public class SimplePoint {
private double x,y;
public SimplePoint(double x1, double y1) {
x = x1;
y = y1;
}
public double getX() { return x; };
public double getY() { return y; };
public double distance(SimplePoint p) {
return Math.sqrt( Math.pow(p.getX()-x,2) + Math.pow(p.getY()-y,2) );
}
}
Sample Runs:
Enter four pairs of x,y coordinates: 1.0 1.0 2.0 2.0 3.0 3.0 4.0 4.0 The point that's furthest from 0,0 is x,y 4.0,4.0 with distance: 5.66.
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."