Design a class named MyPoint to represent a point. The class contains: ➤ Two double private data fields named x and y that specify the coordinates of a point. ➤ A pubic no-arg constructor that creates a default point (0, 0). ➤ A pubic constructor that creates a point with specified x and y coordinates. Two sets of pubic get and set methods for the two private data fields. Write a test class named Lab8 with a main method to create a 2 by 3 array filled with points¹ as follows: (0.5, 1.2) (0.0, 3.14) (6.6, 7.7) (1.2, 2.1) (15.0, 27.5) (12.0, 127.0) In your main method, use a pair of nested for-loops to print the contents of the array. Your output should appear as below:

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Please help me with writing this program. Have to write two different class in which first represent the point and second class is a test program of 2 by 3 array with points. Also help write the UML for this program.  Attatching the insturction and display result in the images.

## Create a 2-D Array of MyPoint Objects

### Objective
Design a class named `MyPoint` to represent a point in a 2-D Cartesian coordinate system. This class will contain the following features:
- **Two double private data fields** named `x` and `y` which specify the coordinates of a point.
- **A public no-arg constructor** that creates a default point at coordinates (0, 0).
- **A public constructor** that creates a point with specified `x` and `y` coordinates.
- **Two sets of public get and set methods** for the two private data fields.

### Instructions
Create a test class named `Lab8` with a `main` method that constructs a 2 by 3 array filled with `MyPoint` objects. The points will be initialized as follows:

\[ \begin{array}{ccc}
(0.5, 1.2) & (0.0, 3.14) & (15.0, 27.5) \\
(6.6, 7.7) & (1.2, 2.1) & (12.0, 127.0) 
\end{array} \]

In your `main` method, use a pair of nested for-loops to print the contents of the array.

### Expected Output
Your output should look like this:

```
Array[0][0] = (0.5, 1.2)
Array[0][1] = (0.0, 3.14)
Array[0][2] = (15.0, 27.5)
Array[1][0] = (6.6, 7.7)
Array[1][1] = (1.2, 2.1)
Array[1][2] = (12.0, 127.0)
```

### Requirements
1. Draw the UML (Unified Modeling Language) diagram of the `MyPoint` class.
2. Implement the `MyPoint` class.
3. Implement the `Lab8` class with the `main` method.

Save the two program files as `MyPoint.java` and `Lab8.java`.

**Note**: The following table represents the required points in the 2D array:

\[ \begin{array}{ccc}
(0.5, 1.2) & (0.0
Transcribed Image Text:## Create a 2-D Array of MyPoint Objects ### Objective Design a class named `MyPoint` to represent a point in a 2-D Cartesian coordinate system. This class will contain the following features: - **Two double private data fields** named `x` and `y` which specify the coordinates of a point. - **A public no-arg constructor** that creates a default point at coordinates (0, 0). - **A public constructor** that creates a point with specified `x` and `y` coordinates. - **Two sets of public get and set methods** for the two private data fields. ### Instructions Create a test class named `Lab8` with a `main` method that constructs a 2 by 3 array filled with `MyPoint` objects. The points will be initialized as follows: \[ \begin{array}{ccc} (0.5, 1.2) & (0.0, 3.14) & (15.0, 27.5) \\ (6.6, 7.7) & (1.2, 2.1) & (12.0, 127.0) \end{array} \] In your `main` method, use a pair of nested for-loops to print the contents of the array. ### Expected Output Your output should look like this: ``` Array[0][0] = (0.5, 1.2) Array[0][1] = (0.0, 3.14) Array[0][2] = (15.0, 27.5) Array[1][0] = (6.6, 7.7) Array[1][1] = (1.2, 2.1) Array[1][2] = (12.0, 127.0) ``` ### Requirements 1. Draw the UML (Unified Modeling Language) diagram of the `MyPoint` class. 2. Implement the `MyPoint` class. 3. Implement the `Lab8` class with the `main` method. Save the two program files as `MyPoint.java` and `Lab8.java`. **Note**: The following table represents the required points in the 2D array: \[ \begin{array}{ccc} (0.5, 1.2) & (0.0
### Note:
Your output should look **exactly** like the output below and should be able to run test cases.

```
Array[0][0] = (0.5, 1.2)
Array[0][1] = (0.0, 3.14)
Array[0][2] = (15.0, 27.5)
Array[1][0] = (6.6, 7.7)
Array[1][1] = (1.2, 2.1)
Array[1][2] = (12.0, 127.0)
```

This snippet of code demonstrates a two-dimensional array `Array` with indices `[0][0]` to `[1][2]`, along with their respective floating-point values in parenthesis. It is essential to maintain the precision and spacing as exemplified to ensure the correctness of the output during test case evaluations.
Transcribed Image Text:### Note: Your output should look **exactly** like the output below and should be able to run test cases. ``` Array[0][0] = (0.5, 1.2) Array[0][1] = (0.0, 3.14) Array[0][2] = (15.0, 27.5) Array[1][0] = (6.6, 7.7) Array[1][1] = (1.2, 2.1) Array[1][2] = (12.0, 127.0) ``` This snippet of code demonstrates a two-dimensional array `Array` with indices `[0][0]` to `[1][2]`, along with their respective floating-point values in parenthesis. It is essential to maintain the precision and spacing as exemplified to ensure the correctness of the output during test case evaluations.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education