public class Point t private int x; private int y; public void setx(int x) this.
ID: 3747239 • Letter: P
Question
public class Point t private int x; private int y; public void setx(int x) this.x.x public void sety(int y) this.yey public void setXY(int x, int y) x-yi Yay: public boolean IsEqual(Point p) return ((p.x .. x) && (p. y y) ); public void DisplayPoint () System.out.println("+xy: public void movePoint(int deltax, int deltay) (x is increased by deltax and y is increased by geltay public void SetLocation(Point P) (//make point to have the specified location P public static void main(Stringt] args) f // TODO Auto-generated method stub Point P1 new Point ); Point P2 new Point(); P1.setx(5); P1.sety (6); P2.setx(5); P2.setY(6); System.out.println(P1.IsEqual(P2)); P2.setXY (3,4); System.out.println(P1.IsEqual(P2)):
Explanation / Answer
Euclidean distance between 2 points P1(x1,y1) and P2(x2,y2) is given by
D=sqrt((x1-x2)^2+(y1-y2)^2)
In the question P1 is (x,y) and P2 is (0,0) (origin)
Hence the distance becomes sqrt(x*x+y*y)
Which is implemented in the 2nd option
Answer:2nd
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.