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.
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