(Solved):Design a class named Rectangle to represent a rectangle. The class contains the following” 1. Two double data fields named width and height that specify the width and height of the rectangle. The d… View Answer…

 

Question

Design a class named Rectangle to represent a rectangle. The class contains the following”

1. Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both fields.

2. A no-arg constructor that creates a default rectangle.

3. A constructor that creates a rectangle with the specified width and height.

4. A method named getArea() that returns the area of the rectangle.

5.

Scroll to top