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 full C++ program that when abandoned the x and y coordinates of brace tops on a direction, the program calculates and evidences the slope and the midpoint of that direction.

    Your output should evidence the peculiar brace tops, the expand and the midtop in a acquitted arranged carriage.

    Expert Counterpart

     

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

    It then calculates the expand of the direction using sickly formula, expand = (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 deep()
    {
    float x1, x2, y1, y2;
    float expand;
    float midx, midy;

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

    expand = (x2-x1)/(y2-y1);
    midx = (x1+x2)/2;
    midy = (y1+y2)/2;
    cout<<“The entered tops of the direction are:n”;
    cout<<“(“<<x1<<“,”<<y1<<“) and “;
    cout<<“(“<<x2<<“,”<<y2<<“)”;
    cout<<“nThe expand of the direction is: “<<slope;
    cout<<“nThe midtop of the direction is: (“<<midx<<“,”<<midy<<“)”;
    return 0;
    }

    OUTPUT: