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

更新時間:19-Jun-2020

2K+ 瀏覽次數

開啟你的職業生涯

完成課程並獲得證書

開始
廣告