Created
May 6, 2022 09:40
-
-
Save ayoubzulfiqar/eb28d60a44274b15851515f6bbdbdfe1 to your computer and use it in GitHub Desktop.
Thias gist contain all the conversion formulas for the temperature.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// c represents the Celsius value which you will add according to mode of conversion you want. | |
// r represents the Rankine value which you will add according to mode of conversion you want | |
// k represents the Kelvin value which you will add according to mode of conversion you want. | |
// f represents the Fahrenheit value which you will add according to mode of conversion you want | |
class Temperature { | |
double celsiusToFahrenheit(num c) { | |
return (c * 9 / 5 + 32); | |
} | |
double celsiusToRankine(num c) { | |
return (c + 273.15) * 9 / 5; | |
} | |
double celsiusToKelvin(num c) { | |
return (c + 273.15); | |
} | |
double fahrenheitToCelsius(num f) { | |
return (f - 32) * 5 / 9; | |
} | |
double fahrenheitToKelvin(num f) { | |
return (f + 459.67) * 5 / 9; | |
} | |
double fahrenheitToRankine(num f) { | |
return (f + 459.67); | |
} | |
double kelvinToFahrenheit(num k) { | |
return (k * 9 / 5 - 459.67); | |
} | |
double kelvinToCelsius(num k) { | |
return (k - 273.15); | |
} | |
double kelvinToRankine(num k) { | |
return (k * 9 / 5); | |
} | |
double rankineToCelsius(num r) { | |
return (r - 491.67) * 5 / 9; | |
} | |
double rankineToFahrenheit(num r) { | |
return (r - 459.67); | |
} | |
double rankineToKelvin(num r) { | |
return (r * 5 / 9); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment