1 Imperial Gallon = 4.54609188 litres
1 Mile = 1.609344 kilometres1英制加仑=4.54609188升1英里=1.609344千米mpg=每加仑行驶的英里数(miles per gallon)
Description:
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); }}