diff --git a/Meteorology/TemperatureTransfer.cs b/Meteorology/TemperatureTransfer.cs new file mode 100644 index 0000000..45e8b78 --- /dev/null +++ b/Meteorology/TemperatureTransfer.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Calculations.Meteorology +{ + public class TemperatureTransfer + { + /// + /// Transfer °C(celsius) to °K(Kelvin) + /// + /// Temperature in °Celsius + /// Temperature in °Kelvin + public static decimal CelsiusToKelvin(decimal celsius) + { + return celsius + (decimal)273.15; + } + + /// + /// Transfer °K(Kelvin) to °C(Celsius) + /// + /// Temperature in °Kelvin + /// Temperature in °Celsius + public static decimal KelvinToCelsius(decimal kelvin) + { + return kelvin - (decimal)273.15; + } + + /// + /// Transfer °C(Celsius) to °F(Fahrenheit) + /// + /// Temperature in °Celsius + /// Temperature in °Fahrenheit + public static decimal CelsiusToFahrenheit(decimal celsius) + { + return (celsius * (decimal)1.8) + 32; + } + + /// + /// Transfer °F(Fahrenheit) to °C(Celsius) + /// + /// Temperature in °Fahrenheit + /// Temperature in °Celsius + public static decimal FahrenheitToCelsius(decimal fahrenheit) + { + return (fahrenheit - 32) / (decimal)1.8; + } + + /// + /// Transfer °K(Kelvin) to °F(Fahrenheit) + /// + /// Temperature in °Kelvin + /// Temperature in °Fahrenheit + public static decimal KelvinToFahrenheit(decimal kelvin) + { + return CelsiusToFahrenheit(KelvinToCelsius(kelvin)); + } + + /// + /// Transfer °F(Fahrenheit) to °K(Kelvin) + /// + /// Temperature in °Fahrenheit + /// Temperature in °Kelvin + public static decimal FahrenheitToKelvin(decimal fahrenheit) + { + return CelsiusToKelvin(FahrenheitToCelsius(fahrenheit)); + } + + } +}