Question: Question 5: Part A: #include using namespace std; class Rectangle { public: Rectangle(int numLength = 0, int numWidth = 0); void Print() const; Rectangle operator+(Rectangle

Question 5:

Part A:

Question 5: Part A: #include using namespace std; class Rectangle { public:

#include using namespace std;

class Rectangle { public: Rectangle(int numLength = 0, int numWidth = 0); void Print() const; Rectangle operator+(Rectangle rhs); private: int length; int width; };

Rectangle::Rectangle(int numLength, int numWidth) { length = numLength; width = numWidth; }

// No need to accommodate for overflow or negative values Rectangle Rectangle::operator+(Rectangle rhs) {

// ENTER THE MISSING PIECE OF CODE HERE AND TEST IT IN C++ (THANK YOU)

}

void Rectangle::Print() const { cout

int main() { int numLength1; int numWidth1; int numLength2; int numWidth2; cin >> numLength1; cin >> numWidth1; cin >> numLength2; cin >> numWidth2; Rectangle rectangle1(numLength1, numWidth1); Rectangle rectangle2(numLength2, numWidth2); Rectangle sum = rectangle1 + rectangle2; rectangle1.Print(); cout

----------

PART B:

Rectangle(int numLength = 0, int numWidth = 0); void Print() const; Rectangle

#include #include #include using namespace std;

int main() { int numValues; unsigned int i; vector pointsList; vector modifiedList; cin >> numValues; pointsList.resize(numValues); modifiedList.resize(numValues); for (i = 0; i > pointsList.at(i); }

// ENTER THE MISSING PIECE OF CODE HERE AND TEST IT IN C++ (THANK YOU)

cout

------------

PART C:

operator+(Rectangle rhs); private: int length; int width; }; Rectangle::Rectangle(int numLength, int numWidth)

#include #include using namespace std;

int main() { int dataSize; string nameAsked; unsigned int i;

cin >> dataSize;

vector nameList(dataSize); vector ageList(dataSize);

for (i = 0; i > nameList.at(i); cin >> ageList.at(i); }

cin >> nameAsked;

/// ENTER THE MISSING PIECE OF CODE HERE AND TEST IT IN C++ (THANK YOU)

return 0; }

---------

thank you >:D

Four integers are read from input, where the first two integers are the length and width of rectangle1 and the second two integers are the length and width of rectangle2. Complete the function to overload the + operator. Ex: If the input is 161788 , then the output is: Length: 16 units, width: 17 units Length: 8 units, width: 8 units Sum: Length: 24 units, width: 25 units Note: The sum of two rectangles is: - the sum of the lengths of the rectangles - the sum of the widths of the rectangles Integer numValues is read from input. Then numValues doubles are read and stored in vector pointsList. Write a loop that sets modifiedList to pointsList shifted right by one, with the element at the end copied to index 0 . Ex: If the input is 394.067.037.0, then the output is: Original points: 94.067.037.0 Updated points: 37.094.067.0 Integer dataSize is read from input. Then, strings and integers are read and stored into string vector nameList and integer vector ageList, respectively. Lastly, string nameAsked is read from input. Find nameAsked in nameList and output the following: - "The name " - the value of nameAsked - " has value " - the element in ageList at the index of nameAsked in nameList - " and is at index" - the index of nameAsked in nameList End with a newline. Ex: If the input is: 4 Fay 33 Rob 67 abe 31 Jan 60 Abe Then the output is: The name Abe has value 31 and is at index 2 Note: nameAsked is an element in nameList

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!