Question: PLEASE DO NOT COPY PASTE FROM CHEGG/OTHERWISE I'LL REPORT YOU . ITEC 243 - Lab 5 - Task 1 Design a rectangle class with the
PLEASE DO NOT COPY PASTE FROM CHEGG/OTHERWISE I'LL REPORT YOU
. ITEC 243 - Lab 5 - Task 1 Design a "rectangle" class with the following private attributes (data members): - length, width and the following methods: (Use this pointer in the member functions) A constructor method which will prompt (ask) the user to enter data member values - A constructor which will receive the 2 data member values as parameter A method rect_area() which will calculate the area of the rectangle and return this value to main function for processing. (Hint: area=length*width) A method rect_perimeter() which will calculate the circumference of the rectangle and return it to main function for processing. (Hint: perimeter=2* (length+width)) A method setrect_dim() which will receive the rectangle's new length and new width from the main function. A method show which will display the current length and width of the rectangle. - A destructor method which will display the deleted objects. Save above class definition as "rect.h" header file. Then write a separate C++ program (rect.cpp) to do the following: Create a rectangle object "rectPtr1". Create a pointer object called "rptri" to point a rectangle object WrectPtr1". Create rectangle object rectPtr2 with length=3 and width=7. Create a pointer object called "rptr2" to point rectangle object "rectPtr2". Display the area of rptri Display the perimeter of rptri Display the length and width of rptr1 . Display the area of rptr2. Display the perimeter of rptr2. Display the length and width of rptr2 . Change the length of the rptr1 to 5 and the width to 8. Display the area of rptr1 . Display the perimeter of rptri Display the length and width of rptri. Create an array object for 4 rectangles called "rectPtr3". Create a pointer object called "recrArtPtr" to point "rectPtr3" array object Display the area and perimeter of array objects. Find and display the average area and perimeter of array objects. Desired Output: Enter length, width: 10 20 Length - 10 Width - 20 Area of first object 200 Perimeter of first object 68 Length = 3 Width = ? Area of second object 21 Perimeter of second object 20 Length - 8 Width - 5 New Area of first object 48 New Perineter of first object 26 Enter length. width : 12 15 Enter length, width : 15 20 Enter length, width: 20 25 Enter length, width: 20 30 Area of 1. object 180 Perimeter of i. object 54 Area of 2. object 300 Perineter of 2. object 70 Area of 3. object 580 Perineter of 3. object 90 Area of 4. object 600 Perimeter of 4. object 100 Average area : 395 Average perimeter : 78 Press any key to continue : The rectangle object with 29 and 38 values has been deleted.. The rectangle object with 20 and 25 values has been deleted. The rectangle object with 15 and 20 values has been deleted. The rectangle object with 12 and 15 values has been deleted. The rectangle object with 3 and 7 values has been deleted.. The rectangle object with 8 and 5 values has been deleted... Press any key to continue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
