您可以使用以下公式将摄氏度转换为华氏度
fahrenheit = celsius * 1.8 + 32
示例:摄氏度转华氏度
// program to convert celsius to fahrenheit
// ask the celsius value to the user
const celsius = prompt("Enter a celsius value: ");
// calculate fahrenheit
const fahrenheit = (celsius * 1.8) + 32
// display the result
console.log(`${celsius} degree celsius is equal to ${fahrenheit} degree fahrenheit.`);
输出
Enter a celsius value: 55 55 degree celsius is equal to 131 degree fahrenheit.
在上面的程序中,用户输入的摄氏度值存储在 celsius 变量中。然后使用华氏度公式将摄氏度转换为华氏度。
您可以使用以下公式将华氏度转换为摄氏度
celsius = (fahrenheit - 32) / 1.8
另请阅读