Question: Write a Rectangle class (interface and implementation) that has the following data members: length: a double width: a double The class should have the following

Write a Rectangle class (interface and implementation) that has the following data members:

length: a double

width: a double

The class should have the following member functions:

Constructor. Accepts the length, and width as arguments by reference.

setLength(...), setWidth() as the setter functions.

getLength(...) and getWidth() as the getter functions.

getArea() returns the area of rectangle

Write a client program that creates two Rectangle objects by asking the user prompt for the length and width of the rectangles and then reports each rectangle's area.

Create a function compareArea(...) that has objects as two parameters. It compares the areas of the two rectangles and displays which has more/equal area.

Input Validation: Do not accept negative values for the radius.

Example output:

Enter the length and width for rectangle 1 in cm: 3, 6

Area: 18 cm sq.

Enter the length and width for rectangle 2 in cm: 5, 3

Area: 15 cm sq.

Rectangle 1 has more area.

in C++

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!