How to keep two decimal places in rate?
double rate;
double pi = Math.PI;
rate = fuel / distance ;
Console.WriteLine("Your fuel consumption rate is " + rate * 100 + "lt" + "/100km");
How to keep two decimal places in rate?
double rate;
double pi = Math.PI;
rate = fuel / distance ;
Console.WriteLine("Your fuel consumption rate is " + rate * 100 + "lt" + "/100km");
You can Display them as like the following, where Math.Round() will help you to store rounded decimal in rate
rate = Math.Round((fuel / distance),2);
Console.WriteLine("Your fuel consumption rate is {0} lt/100km", (rate * 100).ToString("#.##"));