Question: Design a class named Rectangle to represent a rectangle. The class will contain: * Two double data members to hold the width and height of
Design a class named Rectangle to represent a rectangle. The class will contain: * Two double data members to hold the width and height of the rectangle; * A default constructor that creates a rectangle with width and height equal to 1.0; * A constructor that accepts two parameters of type double and creates a rectangle with the width and height equal to the values of its parameters; * Accessor and mutator functions for all the data members; * A member function getArea() that returns the area of the rectangle; * A member function getPerimeter() that returns the perimeter of the rectangle. Write a main function that uses the Rectangle class; the program will prompt the user to enter values for width and height of the rectangle, then create a Rectangle object with the specified values and output the rectangle's area and perimeter.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
