← Back
Introduction
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:
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
- Prompting a user for input
- Saving user input to variables
- Performing arithmetic and saving results to variables
- Formatting output using variables
Challenge Tasks
- Create a console project named CodeChallenge8LineSlopeCalculator.
- Complete the folowing tasks:
- Prompt the user to enter four values corresponding to two points of a line i.e. (x1, y1) and (x2, y2).
- Calculate the slope using the Slope Formula.
- Display the answer to the user. Consider rounding your answer to a decimal place.
Sample Output