Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Construct a class named rectangle that has floating point data members named len

ID: 3627398 • Letter: C

Question

Construct a class named rectangle that has floating point data members named length and width.
The class should have a member functions named perimeter( ) and area( ) to calculate the perimeter and area of a rectangle, a member function named setdata( ) to set a rectangle’s length and width, and a member function named showdata( ) that display’s a rectangle’s length, width, perimeter, and area.

Include the Rectangle class constructed in your C++ program. Your program should ask the user to input the length and width of a rectangle then use the function setdata to set the length and width. It should use the methods or functions perimeter( ), and area( ) to calculate the perimeter and area , finally display the length, width, perimeter, and area using the showdata( )

User hits Escape key to exit the program, otherwise asks data for next rectangle.
ASC code for ESC is 27

Use the following as guideline
// define the class
Class Rectangle
{
Private:
float length
float width
public:
rectangle(); //constructor
void setdata(float, float); // function to set the values
float perimeter(); // function to calculate perimeter. Formula: (2*length+ 2*width)

//other functions declarations go here. The formula for area is (l*w)
};

You should implement each member function as a separate function and test your program with the main function as follows:

Int main()
{
rectangle myrectangle;
float l, w; perim, ara
cin<< l;
cin<<w;
// call setdata to transfer the data
// call functions to calculate and return perimeter, and area. Call function to display data
//
Return 0
}

Explanation / Answer

hope it helps, let me know if you need anything else