C# 程式將華氏度轉換為攝氏度


首先,設定華氏溫度 −

double fahrenheit = 97;
Console.WriteLine("Fahrenheit: " + fahrenheit);

現在將其轉換為攝氏度 −

celsius = (fahrenheit - 32) * 5 / 9;

例子

你可以嘗試執行以下程式碼將華氏度轉換為攝氏度。

線上演示

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo {
   class MyApplication {
      static void Main(string[] args) {
         double celsius;
         double fahrenheit = 97;
         Console.WriteLine("Fahrenheit: " + fahrenheit);
         celsius = (fahrenheit - 32) * 5 / 9;
         Console.WriteLine("Celsius: " + celsius);
         Console.ReadLine();
      }
   }
}

輸出

Fahrenheit: 97
Celsius: 36.1111111111111

更新於: 2020 年 6 月 19 日

2K+ 瀏覽

開啟你的 職業

透過完成課程獲得認證

開始
廣告
© . All rights reserved.