divider

Objective

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:

Line 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

  • icon Prompting a user for input
  • icon Saving user input to variables
  • icon Converting input to the correct data type (if necessary)
  • icon Performing arithmetic calculations
  • icon Formatting custom output using variables
divider

Tasks

  • icon Create a new project named 1-6-line-slope-calculator
  • icon Complete the following tasks:
    • icon Prompt the user to enter four values corresponding to two points of a line i.e. (X1, Y1) and (X2, Y2)
    • icon Calculate the slope using the Slope Formula.
    • icon Optionally, round the answer to three decimal places.
    • icon Display the calculated slope to the user in a clear and formatted manner.
divider

Sample Output

Sample Output
Enter x1: 2 [Enter]
Enter y1: 3 [Enter]
Enter x2: 12 [Enter]
Enter y2: 14 [Enter]
The slope of the line is 1.1

Begin Challenge