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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started