Question & Answer: turn return Length double Pactangigetarea const retarn vidth 1etath Here is a sample output: Ciscmcs321 Answers Rectangle bin Debug Rectangi…..

C++. Can anyone help me write a program for this? it should look like the one that says “sample output” on the bottom page

turn return Length double Pactangigetarea const retarn vidth 1etath Here is a sample output: Ciscmcs321 Answers Rectangle bin Debug Rectangie. exe This progran will ealeulate the area of a rectangle What is the width? 4 What is the length? 5 Here is the rectangle data: width:4 Length:5 Aree: 20 cisenes321Answers RectangletbirDebug Rectangle.exe This progres will calculate the area of a rectanglo What is the width? T What is the length? 8 Here is the rectangles data Width:7 Length:8 Area: 56

turn return Length double Pactangigetarea const retarn vidth 1etath Here is a sample output: Ciscmcs321 Answers Rectangle bin Debug Rectangie. exe This progran will ealeulate the area of a rectangle What is the width? 4 What is the length? 5 Here is the rectangle’ data: width:4 Length:5 Aree: 20 cisenes321Answers RectangletbirDebug Rectangle.exe This progres will calculate the area of a rectanglo What is the width? T What is the length? 8 Here is the rectangle’s data Width:7 Length:8 Area: 56

Expert Answer

 

Please find my implementation.

Please let me know in case of any issue.

######### Rectangle.h #######

class Rectangle {

private:

int width, length;

public:

// default constructor

Rectangle() {

width = 1;

length = 1;

}

// parameterized constructor

Rectangle(int w, int l) {

width = w;

length = l;

}

void setLength(int l) {

length = l;

}

void setWidth(int w) {

width = w;

}

int getLength() {

return length;

}

int getWidth() {

return width;

}

int getArea() {

return length*width;

}

};

########### RectangleTest.cpp ########

#include <iostream>

#include “Rectangle.h”

using namespace std;

int main() {

int length, width;

cout<<“This program will calculate the area of rectangle.”<<endl;

cout<<“What is the width? “;

cin>>width;

cout<<“What is the length? “;

cin>>length;

// creating Rectangle Object

Rectangle rec;

// setting width and length

rec.setLength(length);

rec.setWidth(width);

// output

cout<<“nHere is the rectangle’s data: “<<endl;

cout<<“Width: “<<rec.getWidth()<<endl;

cout<<“Length: “<<rec.getLength()<<endl;

cout<<“Area: “<<rec.getArea()<<endl;

return 0;

}

Still stressed from student homework?
Get quality assistance from academic writers!