Last active
February 17, 2023 21:47
-
-
Save CodeMan99/56c72e88b55243d09c78938296e3ff83 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env node | |
const [n, u] = process.argv.slice(2); | |
const t = parseFloat(n); | |
function kelvin(value) { | |
const sunK = 5778.0; | |
const sunCodys = 1_000_000_000.0; | |
return (value / sunK) * sunCodys; | |
} | |
function celsius(value) { | |
const k = value + 273.15; | |
return kelvin(k); | |
} | |
function fahrenheit(value) { | |
const c = (value - 32.0) * (5.0 / 9.0); | |
return celsius(c); | |
} | |
switch (u) { | |
case 'k': | |
case 'K': | |
console.log(kelvin(t).toLocaleString(), "Codys"); | |
break; | |
case 'c': | |
case 'C': | |
console.log(celsius(t).toLocaleString(), "Codys"); | |
break; | |
case 'f': | |
case 'F': | |
console.log(fahrenheit(t).toLocaleString(), "Codys"); | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment