Question: NEED HELP: You should complete class Point, by implementing a constructor that initializes the x and y coordinate of a point. Then you should implement

NEED HELP: You should complete class Point, by implementing a constructor that initializes the x and y coordinate of a point. Then you should implement the midpoint() method that returns a Point, which is in the middle of two given points. The coordinates of the middle point should be cut to two decimal points. e.g. 0.38764 should be converted to 0.38. CODE:

/**

* This class creates a point.

*

*/

class Point {

double x;

double y;

/**

* This is the constructor that builds a point

* @param x is the x-coordinate of the point

* @param y is the y-coordinate of the point

*/

public Point(double x, double y) {

// your code goes here.

}

/**

* This method returns the mid point of a line,

* whose two ends are given.

* @param p1 is one end of the line

* @param p2 is the other end of the line

* @return the mid point of the line. Both the

* coordinates are cut to two decimal points.

* e.g. 0.37654 is cut to 0.37

*/

public static Point midpoint(Point p1, Point p2) {

// your code goes here. Task 0

return new Point(0, 0);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!