Иван обнови решението на 17.10.2016 15:01 (преди около 8 години)
+def convert_between_temperature_units(num, unit1, unit2)
+
+ if unit1 == 'C' && unit2 == 'K'
+
+ return num + 273.15
+
+ elsif unit1 == 'C' && unit2 == 'F'
+
+ return 9 / 5 * num + 32
+
+ elsif unit1 == 'C' && unit2 == 'C'
+
+ return num
+
+ elsif unit1 == 'F' && unit2 == 'K'
+
+ return 5 / 9 * (num - 32) + 273
+
+ elsif unit1 == 'F' && unit2 == 'C'
+
+ return (num - 32) * 5 / 9
+
+ elsif unit1 == 'F' && unit2 == 'F'
+
+ return num
+
+ elsif unit1 == 'K' && unit2 == 'C'
+
+ return num - 273.15
+
+ elsif unit1 == 'K' && unit2 == 'F'
+
+ return (num - 273.15) * 9 / 5 + 32
+
+ elsif unit1 == 'K' && unit2 == 'K'
+
+ return num
+
+ end
+
+end
+
+def melting_point_of_substance(substance, temperature)
+
+ if temperature == 'C' && substance == 'water'
+
+ return 0
+
+ elsif temperature == 'C' && substance == 'ethanol'
+
+ return -144
+
+ elsif temperature == 'C' && substance == 'gold'
+
+ return 1064
+
+ elsif temperature == 'C' && substance == 'silver'
+
+ return 961.8
+
+ elsif temperature == 'C' && substance == 'copper'
+
+ return 1085
+
+ elsif temperature == 'K' && substance == 'water'
+
+ return convert_between_temperature_units(0, 'C', 'K')
+
+ elsif temperature == 'K' && substance == 'ethanol'
+
+ return convert_between_temperature_units(-144, 'C', 'K')
+
+ elsif temperature == 'K' && substance == 'gold'
+
+ return convert_between_temperature_units(1064, 'C', 'K')
+
+ elsif temperature == 'K' && substance == 'silver'
+
+ return convert_between_temperature_units(961.8, 'C', 'K')
+
+ elsif temperature == 'K' && substance == 'copper'
+
+ return convert_between_temperature_units(1085, 'C', 'K')
+
+ elsif temperature == 'F' && substance == 'water'
+
+ return convert_between_temperature_units(0, 'C', 'F')
+
+ elsif temperature == 'F' && substance == 'ethanol'
+
+ return convert_between_temperature_units(-144, 'C', 'F')
+
+ elsif temperature == 'F' && substance == 'gold'
+
+ return convert_between_temperature_units(1064, 'C', 'F')
+
+ elsif temperature == 'F' && substance == 'silver'
+
+ return convert_between_temperature_units(961.8, 'C', 'F')
+
+ elsif temperature == 'F' && substance == 'copper'
+
+ return convert_between_temperature_units(1085, 'C', 'F')
+
+ end
+
+end
+
+def boiling_point_of_substance(substance, temperature)
+
+ if temperature == 'C' && substance == 'water'
+
+ return 100
+
+ elsif temperature == 'C' && substance == 'ethanol'
+
+ return 78.37
+
+ elsif temperature == 'C' && substance == 'gold'
+
+ return 2700
+
+ elsif temperature == 'C' && substance == 'silver'
+
+ return 2162
+
+ elsif temperature == 'C' && substance == 'copper'
+
+ return 2567
+
+ elsif temperature == 'K' && substance == 'water'
+
+ return convert_between_temperature_units(100, 'C', 'K')
+
+ elsif temperature == 'K' && substance == 'ethanol'
+
+ return convert_between_temperature_units(78.37, 'C', 'K')
+
+ elsif temperature == 'K' && substance == 'gold'
+
+ return convert_between_temperature_units(2700, 'C', 'K')
+
+ elsif temperature == 'K' && substance == 'silver'
+
+ return convert_between_temperature_units(2162, 'C', 'K')
+
+ elsif temperature == 'K' && substance == 'copper'
+
+ return convert_between_temperature_units(2567, 'C', 'K')
+
+ elsif temperature == 'F' && substance == 'water'
+
+ return convert_between_temperature_units(100, 'C', 'F')
+
+ elsif temperature == 'F' && substance == 'ethanol'
+
+ return convert_between_temperature_units(78.37, 'C', 'F')
+
+ elsif temperature == 'F' && substance == 'gold'
+
+ return convert_between_temperature_units(2700, 'C', 'F')
+
+ elsif temperature == 'F' && substance == 'silver'
+
+ return convert_between_temperature_units(2162, 'C', 'F')
+
+ elsif temperature == 'F' && substance == 'copper'
+
+ return convert_between_temperature_units(2567, 'C', 'F')
+
+ end
+
+end