Created
May 19, 2009 19:22
-
-
Save NYiPhoneDeveloper/114328 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
# Converts temperatures | |
class Temperature | |
puts "Put the temperature: \n\ | |
If Fahrenheit, put '75 F' if Celsius, put '75 C' " | |
# This makes temp into: [number, string_(argument)] | |
value = gets() | |
value = value.chomp!.split | |
# This is where I will give the two elments name-value | |
temp = value[0].to_f | |
key_word = value[1].to_s | |
case key_word | |
when key_word = "f" || "F" | |
puts "#{temp} degrees Fahrenheit is equal to \ | |
#{(5.0/9.0 * (temp - 32.0))} degrees celsious" | |
when key_word = "c" || "C" | |
puts "#{temp} degrees Celsius is equal to \ | |
#{(9.0/5.0)*temp + 32} Fahrenheit " | |
else | |
puts "Must be 'f', 'F', 'c', 'C' " | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment