标签:
Miles per gallon to kilometers per liter
1 Imperial Gallon = 4.54609188 litres
1 Mile = 1.609344 kilometres
1英制加仑=4.54609188升
1英里=1.609344千米
mpg=每加仑行驶的英里数(miles per gallon)
Sometimes, I want to quickly be able to convert miles per gallon into kilometers per liter.
Create an application that will display the number of kilometers per liter (output) based on the number of miles per gallon (input).
Make sure to round off the result to two decimal points.
Some useful associations relevant to this kata: 1 Imperial Gallon = 4.54609188 litres 1 Mile = 1.609344 kilometres
using System; public static class Kata { public static double Converter(int mpg) { // do your magic double kpl = mpg * 1.609344 / 4.54609188; return Math.Round(kpl,2); } }
Miles per gallon to kilometers per liter
标签:
原文地址:http://www.cnblogs.com/chucklu/p/4596805.html