Console.Write("Please type in the first floating point number: ");
double floating_1 = Convert.ToDouble(Console.ReadLine());
Console.Write("Please type in the second floating point number: ");
double floating_2 = Convert.ToDouble(Console.ReadLine());
double product = floating_1 * floating_2;
double difference = floating_1 - floating_2;
double sum = floating_1 + floating_2;
Console.WriteLine("The product of the two floating point numbers is: " + product + "\nThe sum of the two floating point numbers is: " + sum + "\nThe difference between the two floating point numbers is: " + difference);
Console.ReadLine();
我有这段代码。每当我执行程序时,小数都没有正确显示(如数字:45.23将显示为4523)。
答案 0 :(得分:1)
我的猜测是您的国家/地区设置设置为使用的国家/地区,而不是。确定小数。
尝试输入例如14,5而不是14.5,看看会发生什么。
c#根据您的国家/地区默认值
解析数字输入并格式化数字输出