Created
May 17, 2012 06:34
-
-
Save MelanieS/2717014 to your computer and use it in GitHub Desktop.
Simple script to find the slope of a straight line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This is just a gist because I felt like writing something | |
#and don't have Ruby installed on the computer I'm using | |
puts "What is the x value for the first point?" | |
x1 = gets | |
puts "What is the y value for the first point?" | |
y1 = gets | |
puts "What is the x value for the second point?" | |
x2 = gets | |
puts "What is the y value for the second point?" | |
y2 = gets | |
y_diff = y1 - y2 | |
x_diff = x1 - x2 | |
slope = y_diff/x_diff | |
"The slope of the line is #{slope}." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment