Question: in c++ please Write a class Rectangle , which has two data members, namely, length and width . It has member functions that calculates and

in c++ please

Write a class Rectangle, which has two data members, namely, length and width. It has member functions that calculates and prints out, the rectangle's perimeter ( ) and area ( ). Write member functions to set and get length and width attributes. You must also provide a default constructor that sets length =0 and width = 0 and a constructor with parameters.

Perimeter = 2*(length + width)

Area =length * width

In the main program do the following:

  • Create an object of type Rectangle.
  • Read the objects length and width from the user.
  • Print the rectangles perimeter and Area to the user.

A sample run is given below:

in c++ please Write a class Rectangle, which has two data members,

Please enter the length and width : 2.2 3.4 Perimeter is : 11.2 Area is : 7.48

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!