Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 , 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 isStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started