Question: Do it in C++ Exercise #1 (50 points): Design and implement C++ class Rectangle. The class defines the following data fields and member functions: 1.


Do it in C++
Exercise #1 (50 points): Design and implement C++ class Rectangle. The class defines the following data fields and member functions: 1. Private double data field named width to store the rectangle width (default value is 1.00). 2. Private double data field named height to store the rectangle height (default value is 1.00) 3. Non-argument (default) constructor function that creates a default rectangle (with default values above). 4. Constructor function that creates a rectangle with specified width and height values from the user. 5. Get functions for the data fields width and height to read their values (i.e., const functions). 6. Function named getArea() that returns the area of the rectangle. 7. Function named get Perimeter() that returns the perimeter of the rectangle. 8. Function pritnRectangle (String objectName) to printout a meaningful description of a rectangle object. Assuming rectangle ABC is 15.00 units wide and 20.00 units high, calling pritnRectangle ("ABC") would display the following output: Rectangle ABC is 15.0 units wide and 20.0 units high. Write a test program (with main() function), named TestRectangle, to create 2 rectangle objects named myRctangle and herRectangle as follows: myRectangle is a default object. (i.e., uses default width and height). herRectangle has width and height values specified by the user. Using proper class functions, display the width, height, area, and perimeter for each object as follows: (the example shows you the output format. Shown values are just for illustration. See Appendix F, page 785 on how to format program outputs) Test data: myRectangle: Width: 1.00 Height: 1.00 Area: 1.00 Perimeter: 4.00 Rectangle myRectangle is 1.0 unit wide and 1.0 unit high. herRectangle: Width: 3.00 Height: 4.00 Area: 12.00 Perimeter: 14.00 Rectangle herRectangle is 30 units wide and 4.0 units high. Allow the user to enter the data values for object herRectangle. Test all class functions on at least one of the objects in a logical order and display meaningful information about the object after each function call
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
