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 thorough C++ program that when loving the x and y coordinates of couple tops on a continuity, the program calculates and exhibits the slope and the midpoint of that continuity.

    Your output should exhibit the ancient couple tops, the extobject and the midtop in a disentangled unconfused mode.

    Expert Exculpation

     

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

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

    And the mid top using the mid-top 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 tops of the continuity are:n”;
    cout<<“(“<<x1<<“,”<<y1<<“) and “;
    cout<<“(“<<x2<<“,”<<y2<<“)”;
    cout<<“nThe extobject of the continuity is: “<<slope;
    cout<<“nThe midtop of the continuity is: (“<<midx<<“,”<<midy<<“)”;
    return 0;
    }

    OUTPUT: