Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a complete program that has the definition of a class Rectangle and a main function. The Rectangle class contains: A private data member length

image text in transcribed
Write a complete program that has the definition of a class Rectangle and a main function. The Rectangle class contains: A private data member length of type integer. A private data member width of type integer. A default constructor that assigns the values 5 and 3 to length and width, respectively. An overloading constructor that accepts two arguments of type integer and assigns them to length and width. An overloading constructor that accepts one argument of type integer and assigns it to both length and width. A member function called getArea that accepts no parameters and returns the area of the rectangle. In your main function declare an array of five rectangles and initialize it using the following partial initialization list: (Rectangle(10,5), Rectangle(8,5), Rectangle(7)). Then use a for loop to display the areas of the five objects in the array as follows: Area of Rectangle 1 13: 50 Area of Rectangle 2 13:40 Area of Rectangle 3 13: 49 Area of Rectangle 4 13: 15 Area of Rectangle 5 13: 15

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

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

=+6 Who is the peer of the IA ?

Answered: 1 week ago

Question

=+herself to in terms of equity with regard to this assignment?

Answered: 1 week ago