-2
我試圖讓Celsius
採取華氏溫度作爲參數,然後在Celsius
函數返回攝氏溫度方法保持返回0
class Exercise1
{
static void Main(string[] args)
{
double fahrenheit;
Console.WriteLine("Enter farenheit: ");
fahrenheit = double.Parse(Console.ReadLine());
double cels;
Exercise1 me = new Exercise1();
cels = me.Celsius(fahrenheit);
Console.WriteLine(cels);
}
public double Celsius(double fahrenheit)
{
double celsius;
celsius = 5/9 * (fahrenheit - 32);
return celsius;
}
已經有很多類似的問題了。即重複(也談到'小數'問題/解決方案是相同的)。或者,如果你只想'雙' - 閱讀這一個 - http://stackoverflow.com/questions/488942/what-is-the-best-practice-to-make-division-return-double-in-c-sharp – 2014-11-24 00:43:28