For C++
• Implement a class that represents a Rectangle, with 2 float side lengths (length, width), and methods to compute the perimeter length and the area.
Expert Answer
class Rectangle {
public:
float length=0; // Length of a rectangle
float width=0; // width of a rectangle
//method to return the perimeter of rectangle
float getPerimeter(void) {
return length + width;
}
//method to return the area of rectangle
float getArea(void) {
return length * width;
}
};