Question: Program#2(25 points): Design and implement a Java class called Rectangle. The class defines the following data fields and methods 1. Private double data field named

 Program#2(25 points): Design and implement a Java class called Rectangle. The

Program#2(25 points): Design and implement a Java class called Rectangle. The class defines the following data fields and methods 1. Private double data field named width to store the rectangle width (default value is 1.0) 2. Private double data field named height to store the rectangle height (default value is 1.0) 3. Non-argument constructor method that creates a default rectangle (with default values) 4. Constructor method that creates a rectangle with specified width and height values 5. Get methods for the data fields width and height. 6. Method named getArea () that returns the area of the rectangle 7. Method named getPerimeter() that returns the perimeter of the rectangle 8. Method toString (to printout a meaningful description of a rectangle object such as (assuming rectangle XYZ width is 5 and height is 10) Rectangle XYZ is 5 units wide and 10 units high Write a test program named TestRectangle to create 3 rectangle objects named myRctangle, hisRectangle, and herRectangle as follows - myRectangle is a default object hisRectangle has width 5 and height 10 - herRectangle has width 5.75 and height 12.50 Using proper methods, display the width, height, area, and perimeter for each object. For example myRectangle: Width: Height: Area: Perimeter: 4 hisRectangle: Width: Height: Area: Perimeter: 30 10 50 Using method toString), display a meaningful description for each rectangle object. For example, Rectangle myRectangle 1S l unit wide and l unit high. Rectangle hisRectangle is 5 units wide and 10 units high

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!