Skip to content

Instantly share code, notes, and snippets.

@MelanieS
Created May 17, 2012 06:34
Show Gist options
  • Save MelanieS/2717014 to your computer and use it in GitHub Desktop.
Save MelanieS/2717014 to your computer and use it in GitHub Desktop.
Simple script to find the slope of a straight line
#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