Question
C++ Code Needed for Lab! Let l be a line in the x-y plane. If l is a vertical line, its equation is x =
C++ Code Needed for Lab!
Let l be a line in the x-y plane. If l is a vertical line, its equation is x = a for some real number a.
Suppose l is not a vertical line and its slope is m. Then the equation of l is y = mx + b, where b is the y-intercept.
If l passes through the point (x, y), the equation of l can be written as y - y = m(x - x).
If (x, y) and (x, y) are two points in the x-y plane and x x, the slope of line passing through these points is m = (y - y)/(x - x).
Instructions
Write a C++ program that prompts the user for two points in the x-y plane. Input should be entered in the following order:
- Input x
- Input y
- Input x
- Input y
The program:
- Outputs the equation of the line
- Uses if statements to determine and output whether the line is vertical, horizontal, increasing, or decreasing.
If l is a non-vertical line, output its equation in the form y = mx + b.
Note: Output all numbers with a precision of two decimal places.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started