How to create a java program that have output like to draw lines and the gets the value of width and length. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to create a java program that have output like to draw lines and the gets the value of width and length.

Create a class that uses the Point class to implement a Rectangle. The Rectangle class has two data members/attributes private Point upperLeft - to represent upper left coordinate  private Point lowerRight - to represent the lower right coordinate. Implement the correct constructor for the Rectangle class -- See Line for guidance--. Implement the necessary get and set methods for the class and toString and equals methods Implement the following methods:  public double length()  - that returns the length of the rectangle  public double width()  - that returns the width of the rectangle public double area()  - that returns the area of the rectangle by calling the length() and width()  public double perimeter()  - that returns the perimeter of the rectangle by calling the length() and width() Formula area = length() * width() perimeter = 2* length() + 2* width(

5th Mar 2021, 4:05 AM
ClaraFlor
ClaraFlor - avatar
1 Answer
0
Pls post your try...
5th Mar 2021, 4:33 PM
Jayakrishna 🇮🇳