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

Plese help me on C++ Using CodeBlocks only Define the struct point with componen

ID: 645690 • Letter: P

Question

Plese help me on C++ Using CodeBlocks only

Define the struct point with components xCoordinate, yCoordinate of type double, which you have used in Lab#6.
Based on Lab#6, modify class polyLine to include the following public member functions:
? void set(int); sets numberOfPoints, creates the dynamic array based on the entered numberOfPoints and then asks the user for the coordinates of each point, sets length.
? void findLength(); computes total polyline length and assigns it to length
? void display() const; display the output messages as in the sample output
? point* getEndpoint(); returns a pointer to one of the endpoints specified by user.
? polyline(int = 0); constructor that invokes the set method
? polyline(

Plese help me on C++ Using CodeBlocks only Define the struct point with components xCoordinate, yCoordinate of type double, which you have used in Lab#6. Based on Lab#6, modify class polyLine to include the following public member functions: ? void set(int); sets numberOfPoints, creates the dynamic array based on the entered numberOfPoints and then asks the user for the coordinates of each point, sets length. ? void findLength(); computes total polyline length and assigns it to length ? void display() const; display the output messages as in the sample output ? point* getEndpoint(); returns a pointer to one of the endpoints specified by user. ? polyline(int = 0); constructor that invokes the set method ? polyline(?..); the copy constructor ? mofifyPoint(int, point); modifies one of the points (specified by first parameter) of the polyline to the new entered point (2nd parameter). Maintain a consistent polyline object. ? The destructor TO set the x and y randomly using rand() %20 for the xcoordinate AND rand()%10 for the ycoordinate Sample Input/Output (shallow copy output) testDriver.cpp #include polyline.h void dummyFun(polyline ); int main() { polyline pl1; pl1.set(5); cout

Explanation / Answer

#include

struct point
{
double xcor;
double ycor;
};

class polyLine
{
int n;
point *p;

public:
void set(int i);
void findLength();
void display()
point* getEndpoint();
polyLine(int = 0);
polyLine(polyline &p);
modifyPoint(int i, point &p);
};

void polyLine::set(int i)
{
n=i;
int c;
p=new point[i];

for(c=0;c  {
cout<<"Enter the x coordinate for Point "<   cin>>p[i].xcor;
cout<<"Enter the y coordinate for Point "<   cin>>p[i].ycor;
}
}

void findLength()
{
int c;
double sum;
for(c=0;c {
sum=sum+(p[i+1].x-p[i])(p[i+1].y+p[i].y)/2;
}
}