Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c++ please Write a class Rectangle , which has two data members, namely, length and width . It has member functions that calculates and

in c++ please

Write a class Rectangle, which has two data members, namely, length and width. It has member functions that calculates and prints out, the rectangle's perimeter ( ) and area ( ). Write member functions to set and get length and width attributes. You must also provide a default constructor that sets length =0 and width = 0 and a constructor with parameters.

Perimeter = 2*(length + width)

Area =length * width

In the main program do the following:

  • Create an object of type Rectangle.
  • Read the objects length and width from the user.
  • Print the rectangles perimeter and Area to the user.

A sample run is given below:

image text in transcribed

Please enter the length and width : 2.2 3.4 Perimeter is : 11.2 Area is : 7.48

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_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions