Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+2. How reliable is this existing information?

Answered: 1 week ago

Question

Presentation Aids Practicing Your Speech?

Answered: 1 week ago