Meter :: Kilometer 200 :: 0.200000 3107 :: 3.107 Kilometer :: Meter 5.1 :: 5100 3.219 :: 3219
This is a C# Program to perform conversions of meter to kilometer and viceversa.
This C# Program Performs Conversions of Meter to Kilometer and vice versa.
Here the entered meter value is converted into kilometer and the entered kilometer is converted in terms of meter.
Here is source code of the C# Program to Perform Conversions of Meter to Kilometer and vice versa. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Perform Conversions of Meter to Kilometer and viceversa */ using System; class Program { static void Main() { double m1 = 200; Console.WriteLine("Meter :: Kilometer"); double k1 = ConvertDistance.cMtK(m1); Console.WriteLine("{0} :: {1}", m1, k1); double m4 = 3107; double k4 = ConvertDistance.cMtK(m4); Console.WriteLine("{0} :: {1}", m4, k4); double k3 = 5.1; Console.WriteLine(); Console.WriteLine("Kilometer :: Meter"); double m3 = ConvertDistance.cKtM(k3); Console.WriteLine("{0} :: {1}", k3, m3); double k2 = 3.219; double m2 = ConvertDistance.cKtM(k2); Console.WriteLine("{0} :: {1}", k2, m2); Console.Read(); } } public static class ConvertDistance { public static double cMtK(double meters) { return meters / 1000; } public static double cKtM(double kilometers) { return kilometers * 1000; } }
In this C# program, the entered meter value is converted into kilometer, and the entered kilometer is converted in terms of meter by calling cMtk() function and cKtm() function by passing the miles and kilometers variable values as an argument. Print the conversions of meter to kilometer and viceversa.
Meter :: Kilometer 200 :: 0.200000 3107 :: 3.107 Kilometer :: Meter 5.1 :: 5100 3.219 :: 3219