Inches to Centimeters Console App

[code language=”csharp”]

/* Mark Hesser
* Dec 10, 17
* Inches to Centimeters */

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

namespace InchesToCentimeters
{
class Inches
{
static void Main(string[] args)
{
Console.Title = "Inches to Centimeters";

//Declarations
const double centimetersInAnInch = 2.54;
double inches, centimeters;

//Example Conversion
inches = 3;
centimeters = inches * centimetersInAnInch;

//Opening Statement
Console.WriteLine("This program converts Inches to Centimeters. " +
"\nFor Example: {0} inches is {1} centimeters", inches, centimeters);

Console.Write("\nHow many Inches: ");

//Input Inches
while (!Double.TryParse(Console.ReadLine(), out inches))
{
//Displayed if a number is not entered
Console.WriteLine("That is not a number…");
Console.Write("\nHow many Inches: ");
}

//Calculation
centimeters = inches * centimetersInAnInch;

//Display Conversion
Console.WriteLine("{0} inches is {1} centimeters", inches, centimeters);

Console.WriteLine("\nPress any key to Exit"); Console.ReadKey();
}
}
}
[/code]