Created
May 12, 2009 19:52
-
-
Save NYiPhoneDeveloper/110694 to your computer and use it in GitHub Desktop.
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
# 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