C# 程式用於執行攝氏度到華氏度的轉換


首先,設定攝氏度 −

double celsius = 36;
Console.WriteLine("Celsius: " + celsius);

現在轉換為華氏度

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

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

例項

線上演示

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Demo {

   class MyApplication {

      static void Main(string[] args) {

         double fahrenheit;

         double celsius = 36;
         Console.WriteLine("Celsius: " + celsius);

         fahrenheit = (celsius * 9) / 5 + 32;
         Console.WriteLine("Fahrenheit: " + fahrenheit);

         Console.ReadLine();
      }
   }
}

輸出

Celsius: 36
Fahrenheit: 96.8

更新於: 19-Jun-2020

7K+ 次觀看

啟動你的職業生涯

透過完成課程獲得認證

立即行動
廣告