Create a method called “Menu” to print the following menu: A – Convert Pounds to Kilograms B – Convert Miles to Kilometers X – Exit the application 2. In the Main() In the Main() method, loop through the “Menu” to give options to the user. Collect the value the user has chosen. If an invalid value is pressed, show “Invalid Input” message and show the menu again
private static void Menu( )
{
bool input = true;
while (input)
{
Console.Clear();
Console.WriteLine("A – Convert Pounds to Kilograms");
Console.WriteLine("B – Convert Miles to Kilometers");
Console.WriteLine("X – Exit the application");
ConsoleKeyInfo c = Console.ReadKey();
if (c.KeyChar == 'A' || c.KeyChar == 'B' || c.KeyChar == 'X')
{
input = false;
}
else
{
Console.WriteLine();
Console.WriteLine("Invalid Input");
Console.ReadKey();
}
}
}
Comments
Leave a comment