Question: can someone fill in the code? //Include the Rectangle.h as follows. Since it is a user defined header //we use Rectangle.h instead of /*--------------------------------------------------------------------------- //
can someone fill in the code? //Include the Rectangle.h as follows. Since it is a user defined header //we use "Rectangle.h" instead of/*--------------------------------------------------------------------------- // AUTHOR: (Put your name here) // FILENAME: Lab8.cpp // SPECIFICATION: This program is the application program that uses the Rectangle class // It creates Rectangle objects and works on these objects. // // INSTRUCTIONS: Read the following code skeleton and add your own code // according to the comments. Ask your TA or your class- // mates for help and/or clarification. When you see // //--> that is where you need to add code. //-------------------------------------------------------------------------*/ #include // Include the Rectangle.h file //--> using namespace std; int main() { //Create Rectangle object r1 using Constructor that does not take any arguments. //NOTE how the object is created without passing any values. Rectangle r1; //Now Create Rectangle object r2 using Constructor that takes two integer arguments (2,2). //You need to use CONSTRUCTOR 2 defined in Rectangle.cpp and it takes two arguments Rectangle r2(2,2); //Lets print the details of Rectangles r1 and r2 //Notice how we use the get functions to get the length and width of the rectangle cout<<"Rectangle r1 details: r1[length="< //Lets print the Perimeter of Rectangle r1 cout<<"Rectangle r1 Perimeter = "< //Lets print the area of Rectangle r1 cout<<"Rectangle r1 Area = "< // Define 2 integer variables length and width and take them as input from user. //--> cout << "Please enter the length of the first rectangle: "; //--> cout << "Please enter the width of the first rectangle: "; //--> //lets change the length and width of rectangle r1 from [0,0] to [length,width] // Change the length of r1 to r1.setLength(length); //Change the width of r1 to //--> //Lets the print the new details of Rectangle r1 cout<<"Rectangle r1 details: r1[length="< //Calculate the new area of r1 and print it //--> //Lets use the isSquare() function to check if the Rectangles r1 and r2 are squares if(r1.isSquare()) cout<<"Rectangle r1 is a square "; else cout<<"Rectangle r1 is NOT a square "; //Check if Rectangle r2 is a square and print if it so (similar to above) //--> return 0; }
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
