Ask Question
20 March, 14:23

Write a C# Console application that converts a mile into its equivalent metric kilometer measurement. The program asks the user to input the value of miles to be converted and displays the original miles and the converted value. Test your code with inputs (1) 10 miles, (2) 3.25 miles.

+1
Answers (1)
  1. 20 March, 14:40
    0
    Following are the program in c#

    using System; / / namespace system

    using System. Collections. Generic; / / namespace collection

    using System. Linq;

    using System. Text;

    namespace test / / namespace

    {

    class Program1 / / class

    {

    static void Main (string[] args) / / Main function

    {

    double nMiles, nKm;

    Console. Write ("Enter Value In Miles : ");

    nMiles = Convert. ToDouble (Console. ReadLine ());

    nKm = (nMiles / 0.62137);

    Console. WriteLine ("Output:");

    Console. WriteLine ("Value In Miles : " + nMiles);

    Console. WriteLine ("Value In KM : " + nKm);

    Console. Read ();

    }

    }

    }

    Output:

    Case A-

    Enter Value In Miles : 10

    Value In Miles : 10

    Value In KM : 16.09347

    Case B-

    Enter Values In Miles : 3.25

    Value In Miles : 3.25

    Value In KM : 5.230378

    Explanation:

    Here we take a input value in "nMiles" variable and converted into a Km. that will stored in "nkm" variable. To convert miles into km we use calculative formula Km = (miles/0.62137). This formula convert the entered value into km and finally print the value of miles and km miles variable.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a C# Console application that converts a mile into its equivalent metric kilometer measurement. The program asks the user to input ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers