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:
#include
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:
#include
int main() { int numValues; unsigned int i; vector
// ENTER THE MISSING PIECE OF CODE HERE AND TEST IT IN C++ (THANK YOU)
cout
------------
PART C:
#include
int main() { int dataSize; string nameAsked; unsigned int i;
cin >> dataSize;
vector
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 nameListStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started