首页 > 其他 > 详细

Miles per gallon to kilometers per liter

时间:2015-06-24 10:31:57      阅读:242      评论:0      收藏:0      [点我收藏+]

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)

 

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);
  }
}

 

Miles per gallon to kilometers per liter

原文:http://www.cnblogs.com/chucklu/p/4596805.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!