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

Given the x, y coordinates of two points in rectangular space (x1, y1) and (x2,

ID: 3674040 • Letter: G

Question

Given the x, y coordinates of two points in rectangular space (x1, y1) and (x2, y2), write a program to calculate (see instructions on board for equations) The distance between the two points The slope of the line The intercept of the line with the y axis The equation of the line The program should prompt (ask) the user for x1, y1, x2, y2 and output as in the following example output (your output should be similar in format to the output below) The distance between the two point is: 4 The slope is: -1.5 The intercept is: 3.6 The equation of the line is: Y = -1.5 X + 3.6

Explanation / Answer

x1 = input("x1");
y1 = input("y1");
x2 = input("x2");
y2 = input("y2");
distance = sqrt((x1-x2)*(x1-x2) + (y1-y2) * (y1 - y2));
m = (y2 - y1) / (x2 - x1);
c = y1 - m * x1;
dis = ["The distance between the two points is:",num2str(distance)] ;
disp(dis)
dis = ["The slope is:                          ",num2str(m)];
disp(dis)
dis = ["The intercept is:                      ",num2str(c)];
disp(dis)
dis = ["The equation of the line is:           Y = ",num2str(m)," X + ",num2str(c)];
disp(dis)

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