Димитър обнови решението на 17.10.2016 00:10 (преди около 8 години)
+def convert_between_temperature_units(temperature, convert_from, convert_to)
+ scale_convertions = {
+ "F" => {
+ "F" => temperature,
+ "C" => ((temperature - 32.0) * 0.56),
+ "K" => (((temperature - 32.0) * 0.56) + 273.15)
+ },
+ "C" => {
+ "F" => ((temperature * 1.8) + 32),
+ "C" => temperature,
+ "K" => (temperature + 273.15)
+ },
+ "K" => {
+ "F" => ((temperature - 273.15) * 1.8 + 32.0),
+ "C" => (temperature - 273.15),
+ "K" => temperature
+ }
+ }
+ ( scale_convertions[convert_from][convert_to] ).round(2)
+end
+
+def melting_point_of_substance(substance, scale)
+ substance_melting_points_in_celsius = {
+ "water" => 0.0,
+ "ethanol" => -114.0,
+ "gold" => 1064.0,
+ "silver" => 961.8,
+ "copper" => 1085.0
+ }
+ convert_between_temperature_units(substance_melting_points_in_celsius[substance], 'C', scale)
+end
+
+def boiling_point_of_substance(substance, scale)
+ substance_boiling_points_in_celsius = {
+ "water" => 100.0,
+ "ethanol" => 78.37,
+ "gold" => 2700.0,
+ "silver" => 2162.0,
+ "copper" => 2567.0
+ }
+ convert_between_temperature_units(substance_boiling_points_in_celsius[substance], 'C', scale)
+end