Здравко обнови решението на 11.10.2016 17:49 (преди около 8 години)
+def convert_between_temperature_units(degree, current_unit, convert_unit)
+ if current_unit == 'C'
+ if convert_unit == 'C'
+ degree
+ elsif convert_unit == 'F'
+ (degree * 1.8 + 32.0)
+ elsif convert_unit == 'K'
+ (degree + 273.15)
+ end
+ elsif current_unit == 'F'
+ if convert_unit == 'F'
+ degree
+ elsif convert_unit == 'C'
+ (degree - 32) / 1.8
+ elsif convert_unit == 'K'
+ (degree + 459.67) / 1.8
+ end
+ elsif current_unit == 'K'
+ if convert_unit == 'K'
+ degree
+ elsif convert_unit == 'C'
+ (degree - 273.15)
+ elsif convert_unit == 'F'
+ (degree * 1.8 - 459.67)
+ end
+ end
+end
+
+def melting_point_of_substance(substance, unit)
+ if substance == 'water'
+ if unit == 'C'
+ 0
+ elsif unit == 'K' || unit == 'F'
+ convert_between_temperature_units(0, 'C', unit)
+ end
+ elsif substance == 'ethanol'
+ if unit == 'C'
+ -114
+ elsif unit == 'K' || unit == 'F'
+ convert_between_temperature_units(-114, 'C', unit)
+ end
+ elsif substance == 'gold'
+ if unit == 'C'
+ 1064
+ elsif unit == 'K' || unit == 'F'
+ convert_between_temperature_units(1064, 'C', unit)
+ end
+ elsif substance == 'silver'
+ if unit == 'C'
+ 961.8
+ elsif unit == 'K' || unit == 'F'
+ convert_between_temperature_units(961.8, 'C', unit)
+ end
+ elsif substance == 'copper'
+ if unit == 'C'
+ 1085
+ elsif unit == 'K' || unit == 'F'
+ convert_between_temperature_units(1085, 'C', unit)
+ end
+ end
+end
+
+def boiling_point_of_substance(substance, unit)
+ if substance == 'water'
+ if unit == 'C'
+ 100
+ elsif unit == 'K' || unit == 'F'
+ convert_between_temperature_units(100, 'C', unit)
+ end
+ elsif substance == 'ethanol'
+ if unit == 'C'
+ 78.37
+ elsif unit == 'K' || unit == 'F'
+ convert_between_temperature_units(78.37, 'C', unit)
+ end
+ elsif substance == 'gold'
+ if unit == 'C'
+ 2700
+ elsif unit == 'K' || unit == 'F'
+ convert_between_temperature_units(2700, 'C', unit)
+ end
+ elsif substance == 'silver'
+ if unit == 'C'
+ 2162
+ elsif unit == 'K' || unit == 'F'
+ convert_between_temperature_units(2162, 'C', unit)
+ end
+ elsif substance == 'copper'
+ if unit == 'C'
+ 2567
+ elsif unit == 'K' || unit == 'F'
+ convert_between_temperature_units(2567, 'C', unit)
+ end
+ end
+end