Question: For C++ -- Create a class Rectangle. Class Rectangle has two private member variables, int length and int width. Class Rectangle has a parametrized constructor

For C++ --

Create a class Rectangle. Class Rectangle has two private member variables, int length and int width. Class Rectangle has a parametrized constructor that accepts two argument for length and width and sets the values of member variables length and width. Class Rectangle has three public member functions, double getlength() that returns length, double getwidth() that returns the width, and double getarea() that returns the area by multiplying length and width.

Class Room has two private member variables, int height and a pointer to class Rectangle *prec. It has a constructor that accepts the arguments for height and pointer to Rectangle class and sets the value of member variables height and prec. Class Room has a public member function getamount(double cost) that accepts the cost of painting per square foot and returns the total amount required to paint the room (ceiling and four walls only),

return (area of ceiling+ 2*length*height + 2*width*height)*cost

Create an object of class Rectangle. Create an object of class Room. Display the amount that is required to paint the room.

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!