Write a class MyPoint and a public class PointApp.
- Two constructors:
MyPoint()creates the origin by calling the other one withthis(0, 0);MyPoint(double x, double y). - Two methods with the same name:
distance(double x, double y)anddistance(MyPoint other)— the second must reuse the first. midpoint(MyPoint other)returns a newMyPoint;equals(MyPoint other)compares the coordinates;toString()gives(1.0, 2.0).
main reads the coordinates of two points p and q. For the input
0 0 3 4
the program prints
p = (0.0, 0.0), q = (3.0, 4.0)
p to q: 5.000
p to (3.0, 4.0): 5.000
p to the origin: 0.000
Midpoint: (1.5, 2.0)
Midpoint to p and to q: 2.500 and 2.500
p equals q: false
p equals a new point with the same coordinates: true