Skip to content

Instantly share code, notes, and snippets.

@NYiPhoneDeveloper
Created May 19, 2009 19:22
Show Gist options
  • Save NYiPhoneDeveloper/114328 to your computer and use it in GitHub Desktop.
Save NYiPhoneDeveloper/114328 to your computer and use it in GitHub Desktop.
# 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