← Back

Code Challenge 8 - Line Slope Formula


When graphing lines in Algebra, it’s important to understand how to calculate the slope of a line. To calculate the slope, at least two points must be identified. You can then calculate the slope using the Slope Formula. The Slope Formula is defined as:

Slope Formula

where m is the slope, the ordered pair (x1, y1) is the first point, and the ordered pair (x2, y2) is the second point.

Skills to Practice

Challenge Tasks

  1. Create a console project named CodeChallenge8LineSlopeCalculator.
  2. Complete the folowing tasks:
    1. Prompt the user to enter four values corresponding to two points of a line i.e. (x1, y1) and (x2, y2).
    2. Calculate the slope using the Slope Formula.
    3. Display the answer to the user. Consider rounding your answer to a decimal place.

Sample Output