Skip to content

Instantly share code, notes, and snippets.

@rakibdevs
Created January 9, 2021 04:24
Show Gist options
  • Save rakibdevs/d89aace0fa92496ee6ec80ae0d14a81c to your computer and use it in GitHub Desktop.
Save rakibdevs/d89aace0fa92496ee6ec80ae0d14a81c to your computer and use it in GitHub Desktop.
Temperature conversions are performed by using a formula, which differs depending on the two temperature scales you are converting between. For example, to convert 50 degrees Celsius (centigrade) to Fahrenheit, we plug our numbers into the formula as shown below: F = C * 9/5 + 32 F = 50 * 9/5 + 32 F = 90 + 32 F = 122 50 degrees Celsius is equal …
<?php
class TemparatureConvert
{
private function kelToCel($num)
{
return round($num - 273.15, 2);
}
private function celToFar($num)
{
return round(($num * 9/5 + 32),2);
}
private function celToKel($num)
{
return round($num + 273.15, 2);
}
private function farToKel($num)
{
return round((($num + 459.67) * 5/9),2);
}
private function farToCel($num)
{
return round(($num - 32) * 5/9, 2);
}
private function farToKel($num)
{
return round((($num + 459.67) * 5/9),2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment