I did a program that used two cpp files and one header file and i have done all
ID: 3551596 • Letter: I
Question
I did a program that used two cpp files and one header file and i have done all of it but the 5 step of the assignment ask:
5. Test the performance of your class by performing the following tasks in your program in the given order: A) declare object 1 with no parameters. B) Declare object 2 with valid parameters for the length (7.1) and width (3.2). C) declare object 3 with only a length (6.3) parameter. D) Declare object 4 with invalid parameters for length and width. E) Declare object 5 and initilaize it by assigning object 2 F) Display the length, width, perimeter, and area of all 5 objects and indicate whether or not they are squares. G) Change the length of object 1 to 5.4 and the width to 10.5. H) Change the length of object 4 to 15.6 and the width to 15.6 I) Display the length, width, perimeter, and of all 5 objects and indicate whether or not they are squares.
Here is my code of the Cpp file with steps A-F:
#include <iostream>
#include <iomanip>
#include <cmath>
#include "rectangle.h"
using namespace std;
int main()
{
Rectangle objectOne;
Rectangle objectTwo(7.1, 3.2);
Rectangle objectThree(6.3);
Rectangle objectFour(200,300);
Rectangle objectFive = objectTwo;
cout << "The first objects information is ";
objectOne.printInfo();
cout << "The second objects information is ";
objectTwo.printInfo();
cout << "The third objects information is ";
objectThree.printInfo();
cout << "The fourth objects information is ";
objectFour.printInfo();
cout << "The fifth objects information is ";
objectFive.printInfo();
}
My question is how i do steps G and H am i suppose to just change what i declared them as at the top there or do something else?
here is the header file:
#ifndef Rectangle_H
#define Rectangle_H
class Rectangle
{
public:
Rectangle();
Rectangle(double length);
Rectangle(double length, double width);
~Rectangle();
void setLengthAndWidth(double, double);
void setLength(double Length);
void setWidth(double Width);
double calculatePerimeter();
double calculateArea();
bool isSquare();
void printInfo();
double getLength();
double getWidth();
private:
double length;
double width;
};
#endif
Explanation / Answer
Dear, #include #include #include #include "rectangle.h" using namespace std; int main() { Rectangle objectOne; Rectangle objectTwo(7.1, 3.2); Rectangle objectThree(6.3); Rectangle objectFour(200,300); Rectangle objectFive = objectTwo; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.