Question: I already did the class as I asked to do , kindly help me with the TestPoint class my codes: import java.lang.*; public class ThePoint

 I already did the class as I asked to do ,

I already did the class as I asked to do , kindly help me with the TestPoint class

my codes:

import java.lang.*;

public class ThePoint {

private int x;

private int y;

public ThePoint() {

x = 0;

y = 0;

}

public ThePoint(int x, int y) {

this.x = x;

this.y = y;

}

public int getX() {

return x;

}

public int getY() {

return y;

}

public double getdistance(ThePoint P) {

return (Math.sqrt(Math.pow (P.getX()-this.getX(), 2))+ (Math.pow (P.getY()-this.getY(), 2))

);

}

}

ThePoint.java Design a class named ThePoint to represent a point with x- and y-coordinates. The class contains Two fields x and y that represents the coordinates. .A no-arg constructor that creates a point (0, 0). A constructor that constructs a point with specified coordinates. Two get methods for data fields x and y, respectively. A method named distance that returns the distance from this point to another point with specified x-and y coordinates TestPoint.java Design a class named TestPoint that receives user input for two points (four values) and displays the coordinates of the points, and also the distance between them. Sample output Program will calculate the distance between two points Enter x value for point 1 Enter y value for point 1 Enter x value for point 2 Enter y value for point 2 The points are (0, ) and (3, 4) The distance between these points is

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!