|
The following C++ program calculates the coefficients of a linear equation given two point in the coordinate plane. The coefficient for the x variable is calculated by subtracting the x values of the points. This corresponds to the horizontal distance component of a vector between the points. The coefficient for the y variable is calculated by subtracting the y values which represents the vertical distance between the points. The constant for the equation is also calculated using the points. The linear equation is displayed in general or standard form. The signs for the coefficients are calculated in a display method for the Line class. The linear equation itself is implemented as a class with a constructor and two other methods.
#include |