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 summits on a cord, the program calculates and spread-outs the slope and the midpoint of that cord.

    Your output should spread-out the primordial brace summits, the arise and the midsummit in a lucid arranged behavior.

    Expert Exculpation

     

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

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

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

    Code:

    #include<iostream>
    using namespace std;

    int deep()
    {
    float x1, x2, y1, y2;
    float arise;
    float midx, midy;

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

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

    OUTPUT: