Reputation: 1059
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();
I have this piece of code. Whenever i execute the program, the decimals aren't showing correctly (Like the number: 45.23 will be shows as 4523).
Upvotes: 0
Views: 258
Reputation: 1815
My guess would be that your country settings are set to a country that uses , instead of . do determine decimals.
try entering for example 14,5 instead of 14.5 and see what happens.
c# parses number input and formats number output in accordance to your country-defaults
Upvotes: 1