Answer to Question #277850 in C# for Rosiee

Question #277850

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


1
Expert's answer
2021-12-10T06:39:00-0500
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();

               }
           }

       }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS