Question: In the Rectangle class, create two private attributes named length and width. Both length and width should be data type double. Task 1 : Write
In the Rectangle class, create two private attributes named length and width. Both length and width should be data type double.
Task : Write public set and get methods to set and get the values for length.
Task : Write public set and get methods to set and get the values for width.
Task : Write a public calculateArea method and a public calculatePerimeter method to calculate and return the area of the rectangle and the perimeter of the rectangle.
This program uses the programmerdefined Rectangle class.
#include "RectangleImp. cpp
#include
using namespace std;
using namespace RectangleImp;
int main
Create Rectangle objects here
Set the lengths and widths here
Print the areas and perimeters here
return ;
Set thelengthofrectangletoand thewidthto Set thelengthofrectangletoand thewidthto
Print the value of rectangles perimeter and area, and then print the value of rectangles perimeter and area.
Namespace RectangleImp
Rectangle
class Rectangle
public:
Declare public methods here
private:
Create length and width here
;
void Rectangle::setLengthdouble len
Write setLength here
void Rectangle::setWidthdouble wid
write setWidth here
double Rectangle::getLength
write getLength here
double Rectangle::getWidth
write getWidth here
double Rectangle::calculateArea
write calculateArea here
double Rectangle::calculatePerimeter
write calculatePerimeter here
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
