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
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP