Design a class named MyPoint to represent a point. The class contains: Two doubl
ID: 3686706 • Letter: D
Question
Design a class named MyPoint to represent a point. The class contains:
Two double data fields named x and y that specify the coordinates of the point.
A constructor that creates a point with a specified width and height.
A method named getX() that returns the x coordinate of a point.
A method named getY() that returns the y coordinate of a point. In your main method create a 2 by 3 array filled with points as follows:
The points are references to the following
In the main method, use a pair of nested for-loops to print the contents of the array.
p01 p02 p03 p10 p11 p12Explanation / Answer
class Test{ public static void main(String[] args) { MyPoint[][] arr = new MyPoint[2][3]; arr[0][0] = new MyPoint(0.5,1.2); arr[0][1] = new MyPoint(0.0,3.14); arr[0][2] = new MyPoint(15.0,27.5); arr[1][0] = new MyPoint(6.6,7.7); arr[1][1] = new MyPoint(1.2,2.1); arr[1][2] = new MyPoint(12.0,127.0); for(int i=0; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.