#!/usr/bin/ruby # f2c: 5*(F - 32)/9 # c2f: 9*C/5 + 32 degrees = ARGV[0] current = degrees[0, degrees.length - 1].to_f fc = degrees[-1,1] if (fc == "f") converted = 5 * (current - 32) / 9 puts "#{current}°F = #{converted}°C" elsif (fc == "c") converted = 9 * current / 5 + 32 puts "#{current}°C = #{converted}°F" else puts "ERROR: #{fc} is not a valid unit of measure." end