From 7ffea6ab49ec76731dc94de30eb09d157a5a7480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Guilherme?= Date: Wed, 4 Oct 2023 15:31:01 -0300 Subject: [PATCH] Adjustments in the calculation of the Fahrenheit temperature, where the last sum of 273.15 was not achieved; Adjustments in the description of the kelvin_to_fahrenheit function, where the calculation description was incorrect, as it describes the formula for calculating fahrenheit to kelvin; Removal of duplicate round, where it was called twice in the last functions. --- conversions/temperature_conversions.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conversions/temperature_conversions.rb b/conversions/temperature_conversions.rb index 090e2bd4..22dfd2e0 100644 --- a/conversions/temperature_conversions.rb +++ b/conversions/temperature_conversions.rb @@ -35,15 +35,15 @@ def self.fahrenheit_to_celsius(fahrenheit_input) # fahrenheit -> kelvin = [(value of fahrenheit - 32) * 5 / 9] + 273.15 => K def self.fahrenheit_to_kelvin(fahrenheit_input) - kelvin_output = ((fahrenheit_input - 32) * 5 / 9).round(2).round(2) + kelvin_output = (((fahrenheit_input - 32) * 5 / 9) + 273.15).round(2) puts "#{fahrenheit_input}°F = #{kelvin_output}K" rescue StandardError puts 'Error: Please provide number only!' end - # kelvin -> fahrenheit = [(value of kelvin - 32) * 5 / 9] + 273.15 => K + # kelvin -> fahrenheit = [(value of kelvin - 273.15) * 9 / 5)] + 32) => K def self.kelvin_to_fahrenheit(kelvin_input) - fahrenheit_output = (((kelvin_input - 273.15) * 9 / 5) + 32).round(2).round(2) + fahrenheit_output = (((kelvin_input - 273.15) * 9 / 5) + 32).round(2) puts "#{kelvin_input}K = #{fahrenheit_output}°F" rescue StandardError puts 'Error: Please provide number only!'