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

Please help write this program in c++ Create a class Rectangle, which stores onl

ID: 3795953 • Letter: P

Question

Please help write this program in c++

Create a class Rectangle, which stores only Cartesian coordinates of four comers of a rectangle as arrays shown below: p4[x4, y4] p3[x3, y3] p1[x1, y1] p2[x2, y2] The constructor calls a set function that accepts four sets of coordinates. The set function verifies that the supplied coordinates do, in fact, form a rectangle. Provide member functions that calculate length, width, perimeter, and area. The length is larger of the two dimensions. Include a predicate function square that determines whether the rectangle is a square. Write a program for the above described rectangle class, compile it, execute it, and demonstrate to your instructor.

Explanation / Answer

I could provide a logic for creating a Rectangle p1,p2,p3,p4.

Observe the following code in C++.

#include<iostream>
using namespace std;

class Rectangle
{
int len,brea;
public:
Rectangle(){};
Rectangle(int i,int j)
{
len=i;
brea=j;
}
void display()
{
cout<<"Length="<<len<<",Breadth="<<brea<<endl;
}
Rectangle operator +(Rectangle);
};
Rectangle Rectangle::operator +(Rectangle obj)
{
Rectangle temp;
temp.len=len+obj.len;
temp.brea=brea+obj.brea;
return(temp);
}
int main()
{
Rectangle p1(5,6),p2(7,8),p3(4,5),p4(6,3),p5;
cout<<"The First Rectangle is:";
p1.display();
cout<<" The Second Rectangle is:";
p2.display();
cout<<" The Third Rectangle is:";
p3.display();
cout<<" The Fourth Rectangle is:";
p4.display();
p5=p1+p2+p3+p4;
cout<<" Result Retangle is:";
p5.display();
}

Based obn the above code you could find area,square and perimeters for those rectangles.I just wrote the logic for creating and Adding Rectangles.