Question: C4.3. (In Java) Design a public class named Rectangle to represent a rectangle. The class contains: double data fields width and length with default values

C4.3. (In Java) Design a public class named Rectangle to represent a rectangle. The class contains:

double data fields width and length with default values of 2 for width and 3 for length

Two constructor methods: o A no-argument contructor that creates a default rectangle o A contructor that creates a rectangle with the specified width and length in the formal parameters

A method named getPerimeter() that returns the perimeter

A method named getArea() that returns the area

Write a simple test program like we did in class that creates two Rectangle objects:

rect1 with default values for width and length

rect2 with width = 3.5 and length = 6.3

Display the perimeter and area of each rectangle.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!