Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aoimakino/5454019 to your computer and use it in GitHub Desktop.
Save aoimakino/5454019 to your computer and use it in GitHub Desktop.
#Conversor celsius a fahrenheit#
def celafah
print "Temperatura en °C"
cel = gets.chomp.to_f
fah = ((cel * 9) / 5) + 32
return fah
end
celafah
def fahacel
print "Temperatura en °F"
fah = gets.chomp.to_f
cel = (fah-32) * (5/9.0)
return cel
end
fahacel
@airvzxf
Copy link

airvzxf commented Apr 24, 2013

Me gusto la forma de resolver lo del redondeo...

Como lograste que redondee a 1 dígito, no entiendo la lógica... en que momento hace lo de 1 digito:
cel = gets.chomp.to_f
fah = ((cel * 9) / 5) + 32

En la segunda no funciona el redondeo:
Temperatura en °F213
100.555555555556

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment