Skip to content

Instantly share code, notes, and snippets.

@NYiPhoneDeveloper
Created May 12, 2009 19:52
Show Gist options
  • Save NYiPhoneDeveloper/110694 to your computer and use it in GitHub Desktop.
Save NYiPhoneDeveloper/110694 to your computer and use it in GitHub Desktop.
# A basic square program - will develop "inches", "ft", "yards" and add more features later!
class Square
# The math is meant for a square only!!
puts "put the side of the square: "
length = gets()
length = length.chomp.to_f
puts "Would you like: \
\np = perimeter \
\nh = hypotenuse \na = area"
ans = gets()
ans = ans.chomp.to_s
hy = Math.sqrt(length*length * 2)
if ans == "p"
puts length * 4
elsif ans == "a"
puts length * length
elsif ans == "h"
puts hy
else
puts "not a valid entery"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment