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:

  1. Outputs the equation of the line
  2. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!