Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Requirement: create one project for each problem; add comments to your code. Sub

ID: 3549853 • Letter: R

Question

Requirement: create one project for each problem; add comments to your code.                 


Submission: after finishing the all the problems, paste the code and snapshot the output in one file, submit it to the dropbox.                 


===================================================                 


Problem 3                 

                    #include <iostream>                 

                    using namespace std;                 

                    #include <iostream>                 

                    using namespace std;                 

                    class Rectangle                 

                    {                 

                    double width, height;                 

                    public:                 

                    Rectangle ();                 

                    Rectangle (double, double);                 

                    double sum_w_h();                 

                    static int count;                 

                    int area (void){return (width*height);}                 

                    };                 

                    int Rectangle::count = 0;                 

                    Rectangle:: Rectangle()                 

                    {                 

                    count = count + 1 ;                 

                    width = 5;                 

                    height = 5;                 

                    }                 

                    Rectangle :: Rectangle (double a, double b)                 

                    {                 

                    width = a;                 

                    height = b;                 

                    }                 

                    double Rectangle :: sum_w_h()                 

                    {                 

                    double z = width + height;                 

                    return z;                 

                    }                 

                    int main ()                 

                    {                 

                    int size =10;                 

                    Rectangle rect[10];                 

                    double sum =0;                 

                    for (int i =0; i<10; i++)                 

                    {                 

                    sum= sum + rect[i].area();                 

                    }                 

                    cout << sum << endl;                 

                    cout << endl;                 

                    cout << Rectangle :: count << endl;                 

                    cin.ignore(2);                 

                    return 0;                 

                    }                 


Explanation / Answer

#include <iostream>

using namespace std;

#include <iostream>

using namespace std;


class Point

{

double x,y;

public Point(int,int);

void set(int,int);

}

point:: point(int a, int b)

{

x = a;

y = b;

}

point:: set(int a,int b){

x=a;

y=b;

}



class Rectangle

{

double width, height;

private Point p;

public:

Rectangle ();

Rectangle (double, double);

void move(int,int);

double sum_w_h();

static int count;

int area (void){return (width*height);}

}

};

int Rectangle::count = 0;

Rectangle:: Rectangle()

{

count = count + 1 ;

width = 5;

height = 5;

}

Rectangle :: Rectangle (double a, double b)

{

width = a;

height = b;

}

double Rectangle :: sum_w_h()

{

double z = width + height;

return z;

}

void Rectangle :: sint(int x2,int y2)

{

p.set(x2,y2);

}

int main ()

{

int size =10;

Rectangle rect[10];

double sum =0;

for (int i =0; i<10; i++)

{

sum= sum + rect[i].area();

}

cout << sum << endl;

cout << endl;

cout << Rectangle :: count << endl;

cin.ignore(2);

/* test */

rect[0].move(1,2);

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote