/***************************************************************************** * Calculates the slope, midpoint, length and equation of the line * * connecting two coordinates on the cartesian plane. * * Inputed: x1, y1 (coor. of first point), x2, y2 (coor of sec point) * * Outputed: slope, midpoint, length, equation [see below] * * Written: September 21, 2001 * * By: Ronald Roberts * *****************************************************************************/ //Program 8 //21SEP01 #include #include int main() { /* declaration of variables */ double x1=0, x2=0, y1=0, y2=0, slope=0, mid1=0, mid2=0, length=0, b=0; /* instructions and user input */ cout<<"This program computes slope, midpoint, and length"<>x1>>y1; cout<<"Please enter the second point(x,y):"<>x2>>y2; /* calculation code */ slope=(y2-y1)/(x2-x1); mid1=(x2+x1)/2; mid2=(y2-y1)/2; length=sqrt(pow((x2-x1), 2)+pow((y2-y1), 2)); b=y1-slope*x1; /* output results */ cout<<"The slope is "<