public static void Main()
        {
            string repeat = "y";

            while (repeat == "y")
            {
                Console.WriteLine("*** Main Menu ***\n\nEnter a number between 1 and 9 to select a program: ");
                int input = Convert.ToInt32(Console.ReadLine());

                if (input > 0 && input < 10)
                {
                    switch (input)
                    {
                    case 1:
                        ProgramQ1.Main();
                        break;

                    case 2:
                        ProgramQ2.Main();
                        break;

                    case 3:
                        ProgramQ3.Main();
                        break;

                    case 4:
                        ProgramQ4.Main();
                        break;

                    case 5:
                        ProgramQ5.Main();
                        break;

                    case 6:
                        ProgramQ6.Main();
                        break;

                    case 7:
                        ProgramQ7.Main();
                        break;

                    case 8:
                        ProgramQ8.Main();
                        break;

                    case 9:
                        ProgramQ9.Main();
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("Number input is not within range. Please try again.");
                }
                Console.WriteLine("Type y to continue OR any key to stop program");
                repeat = Console.ReadLine();
            }
        }
示例#2
0
        public static void Main()
        {
            Console.WriteLine("Enter a number between 1 and 9 to run a program");
            string input = Console.ReadLine();

            switch (input)
            {
            case "1":
                ProgramQ1.Main();
                break;

            case "2":
                ProgramQ2.Main();
                break;

            case "3":
                ProgramQ3.Main();
                break;

            case "4":
                ProgramQ4.Main();
                break;

            case "5":
                ProgramQ5.Main();
                break;

            case "6":
                ProgramQ6.Main();
                break;

            case "7":
                ProgramQ7.Main();
                break;

            case "8":
                ProgramQ8.Main();
                break;

            case "9":
                ProgramQ9.Main();
                break;
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            {
                while (choice == "y")
                {
                    while (programNum != 1 || programNum != 3 || programNum != 4 || programNum != 5)
                    {
                        Console.Clear();
                        Console.WriteLine("--- Main Menu ---\n\nType 1, 3, 4 or 5 for the corresponding program number: ");
                        programNum = int.Parse(Console.ReadLine());
                        //if (int.TryParse(programNum, out int check))
                        switch (programNum)
                        {
                        case 1:
                            ProgramQ1.Main();
                            break;

                        case 3:
                            ProgramQ3.Main();
                            break;

                        case 4:
                            ProgramQ4.Main();
                            break;

                        case 5:
                            ProgramQ5.Main();
                            break;

                        default:
                            Console.WriteLine("invalid input. Please try again.");
                            ////-- https://stackoverflow.com/questions/11512821/how-to-stop-c-sharp-console-applications-from-closing-automatically
                            //System.Threading.Thread.Sleep(1000);
                            //Console.Clear();
                            //Console.WriteLine("Enter y to go back to the main menu, enter n to exit program");
                            //choice = Console.ReadLine();
                            Console.Clear();
                            break;
                        }
                    }
                    Console.WriteLine("Enter y to return to Main Menu, enter n to close program");
                    choice = Console.ReadLine();
                    if (choice == "n")
                    {
                        Console.WriteLine("Program shutting down...");
                        //-- https://stackoverflow.com/questions/11512821/how-to-stop-c-sharp-console-applications-from-closing-automatically
                        System.Threading.Thread.Sleep(1000);
                        //-- https://stackoverflow.com/questions/5682408/command-to-close-an-application-of-console
                        Environment.Exit(0);
                    }
                    while (choice != "y")
                    {
                        Console.WriteLine("invalid input. Try again.");
                        choice = Console.ReadLine();
                        if (choice == "n")
                        {
                            //-- https://stackoverflow.com/questions/5682408/command-to-close-an-application-of-console
                            Environment.Exit(0);
                        }
                    }
                }
            }
        }