Question: Hw 4: Design a class named Rectangle to represent a rectangle. The class contains: Two double data fields named width and height that specify the
Hw 4: Design a class named Rectangle to represent a rectangle. The class contains: Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height A no-arg constructor that creates a default rectangle. A constructor that creates a rectangle with the specified width and height. A method named getArea() that returns the area of this rectangle. A method named getPerimeter() that returns the perimeter. Write a test program that creates three Rectangle objects 1. with default width and height 2. with width 4 and height 40 3. with width 3.5 and height 35.9 Display the width, height, area, and perimeter of each rectangle in this order. Output Hwt 2018F (run)X width: 1.0, height: 1.0 azea: 1.0 perimeter: 4.0 width: 4.O, height: 40.0 azea: 160.0 perimeter: se.0 width: 3.5, height: 35.9 area: 125.64999999999999 perimetez: 78. BUILD SUCCESSPUL (total time: O seconda)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
