Никола обнови решението на 17.10.2016 12:03 (преди около 8 години)
+def convert_between_temperature_units(degrees, first_unit, second_unit)
+ if first_unit == 'C'
+ if second_unit == 'F'
+ degrees = degrees * 1.8 + 32
+ elsif second_unit == 'K'
+ degrees += 273.15
+ end
+ elsif first_unit == 'F'
+ if second_unit == 'C'
+ degrees = (degrees - 32) / 1.8
+ elsif second_unit == 'K'
+ degrees = 273.15 + (degrees - 32) / 1.8
+ end
+ elsif second_unit == 'C'
+ degrees -= 273.15
+ elsif second_unit == 'F'
+ degrees = (degrees - 273.15) * 1.8 + 32
+ end
+ degrees
+end
+
+def melting_point_of_substance(element, unit)
+ elements = {'water' => 0, 'ethanol' => -114, 'gold' => 1_064, 'silver' => 961.8, 'copper' => 1_085}
+ convert_between_temperature_units(elements[element], 'C', unit)
+end
+
+def boiling_point_of_substance(element, unit)
+ elements = {'water' => 100, 'ethanol' => 78.37, 'gold' => 2_700, 'silver' => 2_162, 'copper' => 2_567}
+ convert_between_temperature_units(elements[element], 'C', unit)
+end