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

Miles per gallon to kilometers per liter的更多相关文章

  1. c++ primer plus 第三章 课后题答案

    #include<iostream> using namespace std; int main() { ; int shen_gao; cout <<"Please ...

  2. C Primer Plus(第五版)12

    第 12 章 存储类, 链接和内存管理 在本章中你将学习下列内容 . 关键字: auto, extern, static, register, const, volatile, restricted. ...

  3. c++-pimer-plus-6th-chapter03

    Chapter Review Having more than one integer type lets you choose the type that is best suited to a p ...

  4. ArcGIS Server开发教程系列(8)ArcGIS API for Javascript-控件(小部件)

    1.     鹰眼 OverviewMap小部件用于在其关联的主地图内较清楚的当前鸟瞰图的范围.当主地图范围变化时,鹰眼图会自动在其空间内更新范围以保持和地图的当前范围保持一致,当鹰眼图空间的地图范围 ...

  5. R语言实战(一)介绍、数据集与图形初阶

    本文对应<R语言实战>前3章,因为里面大部分内容已经比较熟悉,所以在这里只是起一个索引的作用. 第1章       R语言介绍 获取帮助函数 help(), ? 查看函数帮助 exampl ...

  6. 深入浅出Symfony2 - 结合MongoDB开发LBS应用

    简介 随着近几年各类移动终端的迅速普及,基于地理位置的服务(LBS)和相关应用也越来越多,而支撑这些应用的最基础技术之一,就是基于地理位置信息的处理.我所在的项目也正从事相关系统的开发,我们使用的是S ...

  7. Scatterplots 散点图

    Simple Scatterplot # Simple Scatterplot attach(mtcars)plot(wt, mpg, main="Scatterplot Example&q ...

  8. ArcGIS Server 开发之鹰眼地图的实现

    鹰眼简单点说就是地图的联动,鹰眼的全称是OverviewMap,在ERSI提供的API包中,在dijit中进行类的调用.查了很多的资料,总结一下: 具体的代码: <!DOCTYPE html&g ...

  9. R 绘图 填充颜色

    d <- density(mtcars$mpg) plot(d, main="Kernel Density of Miles Per Gallon") polygon(d, ...

随机推荐

  1. manifest save for self

    一.使用html5的缓存机制 1.先上规则代码:m.manifest CACHE MANIFEST # 2015-04-24 14:20 #直接缓存的文件 CACHE: /templates/spec ...

  2. html5画图和本地存储

    <!DOCTYPE HTML><html><body> <canvas id="myCanvas" width="200&quo ...

  3. jQuery 图片轮播的代码分离

    以前遇到过jQuery实现列表自动滚动,这次的图片轮播在原理上与之相同,只有一些细微的差别,就是需要在图片的右下角显示当前图片的序号. html代码,以及对应的css代码: <div id=&q ...

  4. IEEE 754 浮点数的四种舍入方式

    四种舍入方向: 向最接近的可表示的值:当有两个最接近的可表示的值时首选"偶数"值:向负无穷大(向下):向正无穷大(向上)以及向0(截断). 说明:默认模式是最近舍入(Round t ...

  5. 初识shell脚本

    shell字符串.shell数组.shell echo指令.shell test命令.shell if语句.shell case语句.shell for语句.shell while语句.shell b ...

  6. C语言字符串与字符数组

    字符串儿与字符数组 字符数组的定义: Char buffer[]; 字符数组初始化: Char buffer1[]="hello world"; 利用scanf输入一个字符串儿 代 ...

  7. EXTJS 3.0 资料 控件之 itemselector 用法

    var dsform = new Ext.data.ArrayStore({ data: [[123, 'One Hundred Twenty Three'], ['1', '今天星期一'], ['2 ...

  8. Linux C程序的编译过程

    Linux C程序的编译过程 学习一门语言程序,本人觉得还是得学习它的编译规则,现在,通过小例子小结下自己对C编译的认识. /*test.c     了解C程序的编译*/ #include <s ...

  9. random note

    今天才慢慢意识到,什么才是学习,(以思考解决问题为驱动),埋头刷分只是方法,不是目的和原动力. 既然准备读研,就要慢慢去了解研究生的生活学习方式是什么样的,涉及到哪些方面. 读研之前要选好方向,但是现 ...

  10. netty sample

    http://netty.io/wiki/ https://github.com/netty/netty/tree/master/example/src/main/java/io/netty/exam ...