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

In C, Actions ? Project 3 Working with Points and Structs-due before 11:59pm on

ID: 3701036 • Letter: I

Question

In C,

Actions ? Project 3 Working with Points and Structs-due before 11:59pm on Wednesday 4/11 Submit your code to the zylab at https://learn.zybooks.com/zybook/UICCS107TheysSpring2018/chapter/11/section/16 Your code must use the following structure struct point struct double xcoor; double ycoor; char label [25]; d: typedef struct point struct Point; the following functions must be created: Point getPoint); I/ read in a point from the user (stdin) double distance (Point pt1, Point pt2); // return the distance between pt1 and pt2 double slope (Point pt1, Point pt2); /* calculate the slope of the line starting at pt1 and going to pt2 void perpPoint (Point pt1, Point pt2, Point *pt3); s calculate pt3 such that a line from ptl to pt3 is perpendicular to the line from pt1 to pt2, and the distance between pt1 and pt2 is the same as the distance between pti and pt3 */ See the zylab for how the input will be formatted.

Explanation / Answer

Point getpoint(){

point temp;

cin>>xcoor>>ycoor;//Enter x and y co-ordinates

return temp;

}

double distance(Point pt1, Point pt2){

double dx = (pt1.xcoor-pt2.xcoor)*(pt1.xcoor-pt2.xcoor);

double dy = (pt1.ycoor-pt2.ycoor)*(pt1.ycoor-pt2.ycoor);

double dist = sqrt(d1+d2);

return dist;

}

double slope(Point pt1, Point pt2){

if(pt2.xcoor==pt1.xcoor)

return INF;

else{

double slope = (pt2.ycoor-pt1.ycoor)/(pt2.xcoor-pt1.xcoor);

return slope;

}

}

void perpPoint(Point pt1, Point pt2, Point *pt3){

double midx=x2-d/sqrt(2);

double midy=y1+d/sqrt(2);

pt3.xcoor=2*midx-x2;

pt3.ycoor=2*midy-y2;

}

int main(){

point_struct pt1=getPoint();

point_struct pt2=getPoint();

point_struct pt3=getPoint();

point_struct pt4=getPoint();

cout<<distance(pt1, pt2)<<" "<<distance(pt3, pt4);

cout<<slope(pt1, pt2)<<" "<<slope(pt3, pt4);

point_struct pt5;

perpPoint(pt1, pt2, &pt5);

return 0;

}