Емине обнови решението на 17.10.2016 15:57 (преди около 8 години)
+def convert_between_temperature_units(degree, from_unit, to_unit)
+ if from_unit == 'C'
+ if to_unit == 'F'
+ degree * 1.8 + 32
+ elsif to_unit == 'K'
+ degree + 273.15
+ else
+ degree
+ end
+ elsif from_unit == 'F'
+ if to_unit == 'C'
+ (degree - 32) / 1.8
+ elsif to_unit == 'K'
+ (degree + 459.67) * 5.0 / 9.0
+ else
+ degree
+ end
+ elsif from_unit == 'K'
+ if to_unit == 'C'
+ degree - 273.15
+ elsif to_unit == 'F'
+ degree * 9.0 / 5.0 - 459.67
+ else
+ degree
+ end
+ end
+end
+
+def melting_point_of_substance(substance, unit)
+ case substance
+ when 'water'
+ convert_between_temperature_units(0, 'C', unit)
+ when 'ethanol'
+ convert_between_temperature_units(-114, 'C', unit)
+ when 'gold'
+ convert_between_temperature_units(1_064, 'C', unit)
+ when 'silver'
+ convert_between_temperature_units(961.8, 'C', unit)
+ when 'copper'
+ convert_between_temperature_units(1_085, 'C', unit)
+ end
+end
+
+def boiling_point_of_substance(substance, unit)
+ case substance
+ when 'water'
+ convert_between_temperature_units(100, 'C', unit)
+ when 'ethanol'
+ convert_between_temperature_units(78.37, 'C', unit)
+ when 'gold'
+ convert_between_temperature_units(2_700, 'C', unit)
+ when 'silver'
+ convert_between_temperature_units(2_162, 'C', unit)
+ when 'copper'
+ convert_between_temperature_units(2_567, 'C', unit)
+ end
+end