Wednesday, 28 October 2015

C# Lab@home 3

Write a C# program that accepts distance in kilometers, converts it into meters, and then displays the result.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Quotient
{
    class Meter_Kilometer
    {
        static void Main(string[] args)
        {
            int nDistance, nResult;
            Console.WriteLine("Enter the distance in kilometers");
            nDistance = Convert.ToInt32(Console.ReadLine());
            nResult = nDistance * 1000;
            Console.WriteLine("Distance in meters:" + nResult);
            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment