Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (24 sloc) 1.029 kB
Developer: Dan Chuparkoff (Twitter: @chuparkoff )
Creation Date: 4/13/2012
Initial Ruby Version: Ruby 1.9.3-p125
Initial Development Environment: Windows 7 Home Premium - SP1
Initial Development IDE: Jetbrains RubyMine 4.0.3
This program was created as an exercise in the RubyLearning PORPC101-32C Course.
This program illustrates extends our use of gets and chomp.
#Variable Initialization
temp_in_fahrenheit = ""
temp_in_celsius = ""
#Collect the Temp from the STDOUT and chomp the /n character.
puts 'Enter temperature in Fahrenheit: '
temp_in_fahrenheit = gets.chomp
#Convert the Fhar. String to Float, then Convert the Value into Celcius
temp_in_celsius = (((temp_in_fahrenheit.to_f - 32.0) / 9.0) * 5.0)
#Display the converted Celcius float in 2 decimal places wrapped in output copy
puts 'Temperature ' + temp_in_fahrenheit + ' degree Fahrenheit = ' + \
format("%.2f", temp_in_celsius) + ' degree Celsius'
Jump to Line
Something went wrong with that request. Please try again.