Skip to content

Instantly share code, notes, and snippets.

@airvzxf
Last active December 16, 2015 15:18
Show Gist options
  • Save airvzxf/5454533 to your computer and use it in GitHub Desktop.
Save airvzxf/5454533 to your computer and use it in GitHub Desktop.
Codecery :: | Beautiful asterisk in console mode | Fahrenheit to Celsius | Celsius to Fahrenheit |
##### Fahrenheit to Celsius
def convert(f)
c = ((f.to_i-32)*(5.0/9.0))
c = (c * 10).round * 0.1
end
puts "Convert Fahrenheit to Celsius."
print "Input the Fahrenheit: "
f = gets
puts "Celcius: °#{convert(f)}"
puts ''
##### Celsius to Fahrenheit
def convert(c)
f = ((c.to_i*(9.0/5.0))+32)
f = (f * 10).round * 0.1
end
puts "Convert Celsius to Fahrenheit."
print "Input the Celsius: "
c = gets
puts "Fahrenheit: °#{convert(c)}"
puts ''
##### Asterisks Pyramid
l = 6
(1..l).each do |a|
l.downto(a) do
print " "
end
1.upto(a) do
print "*"
end
puts ""
end
puts ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment