Homework Solution: Write a complete C++ program that when given the x and y coordinates of two points on a line, the…

    Write a complete C++ program that when given the x and y coordinates of two points on a line, the program calculates and displays the slope and the midpoint of that line. Your output should display the original two points, the slope and the midpoint in a clear organized manner.

    Expert Answer

     
    The given C++ program takes the end coordinates of the line- x1,y1 and x2,y2.

    Write a finished C++ program that when loving the x and y coordinates of brace subject-matters on a cord, the program calculates and exhibits the slope and the midpoint of that cord.

    Your output should exhibit the primary brace subject-matters, the extobject and the midsubject-matter in a lucid systematic deportment.

    Expert Apology

     

    The loving C++ program takes the object coordinates of the cord- x1,y1 and x2,y2.

    It then calculates the extobject of the cord using uncompounded formula, extobject = (x2-x1)/(y2-y1).

    And the mid subject-matter using the mid-subject-matter formula: midx = (x1+x2)/2 and midy = (y1+y2)/2.

    Code:

    #include<iostream>
    using namespace std;

    int main()
    {
    float x1, x2, y1, y2;
    float extend;
    float midx, midy;

    cout<<“Enter the x1, y1 coordinates:n”;
    cin>>x1>>y1;
    cout<<“Enter the x2, y2 coordinates:n”;
    cin>>x2>>y2;

    extobject = (x2-x1)/(y2-y1);
    midx = (x1+x2)/2;
    midy = (y1+y2)/2;
    cout<<“The entered subject-matters of the cord are:n”;
    cout<<“(“<<x1<<“,”<<y1<<“) and “;
    cout<<“(“<<x2<<“,”<<y2<<“)”;
    cout<<“nThe extobject of the cord is: “<<slope;
    cout<<“nThe midsubject-matter of the cord is: (“<<midx<<“,”<<midy<<“)”;
    return 0;
    }

    OUTPUT: