Answer to Question #330964 in C# for Mandeep

Question #330964


 1. [15 marks] Write a new method that will work as the menu of your application. Details: 

  • Name: YourNameMenu – replace “YourName” with your first name. For example: 
  • Parameter: None 
  • Returns: A string representing the choice the user have done for the menu option 
  • Displays: The menu below - It should MATCH EXACTLY the output you see below 
  • Task: Prints out the menu below, collects the user input and returns the input as the method’s return value. 

2. [25 marks] In your Main method, using a “while” loop, not a “do while”, write the code to call the Menu method you have created on question #1 repeatedly. 

Using a “switch” structure, write the code to implement the following required functionality for all valid responses. Valid responses includes both upper and lower case of the input. The following must be implemented: 

- A will call the DemoQuestion3() method 

- B will call the DemoQuestion4() method 

- C will call the DemoQuestion5() method 

- X will terminate the program 

Any other 


1
Expert's answer
2022-04-20T12:40:56-0400
 class Program
    {
        static void Main(string[] args)
        {
            SamMenu();
            while (true)
            {
                Console.Write("Input the option (A, B, C, X): ");
                string input = Console.ReadLine().ToUpper();


                switch (input)
                {
                    case "A":
                        DemoQuestion3();
                        break;
                    case "B":
                        DemoQuestion4();
                        break;
                    case "C":
                        DemoQuestion5();
                        break;
                    case "X":
                        Console.WriteLine("Press any key to close app..");
                        Console.ReadLine();
                        return;
                    default:
                        Console.WriteLine("Incorrect input!");
                        break;
                }
            }


            
        }


        public static void DemoQuestion3()
        {


        }


        public static void DemoQuestion4()
        {


        }


        public static void DemoQuestion5()
        {


        }


        public static void SamMenu()
        {
            Console.WriteLine("Display my menu...");
        }




    }

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