Exemplo n.º 1
0
        static void Main(string[] args)
        {
            int userInputVal = 0;

            do
            {
                userInputVal = AverageScore.ShowMenu();
            } while (userInputVal < 0 && userInputVal < 3);
            AverageScore.AskUserInput();
            //Console.ReadLine();
        }
Exemplo n.º 2
0
        public static void AskUserInput()
        {
            if (UserOption == 1)
            {
                do
                {
                    Console.WriteLine("Enter 10 Comma-Separated scores in the range of 0-100: ");
                    userInput = Console.ReadLine().Split(',');
                    Console.WriteLine("You have entered total of {0} scores", userInput.Length);
                } while (userInput.Length != 10);
            }
            else if (UserOption == 2)
            {
                int len;
                do
                {
                    Console.WriteLine("Enter specific number of scores you want to average: ");
                    string length = Console.ReadLine();
                    if (Int32.TryParse(length, out len))
                    {
                        Console.WriteLine("You want the average grade of {0} scores", len);
                    }
                    else
                    {
                        Console.WriteLine("Length of score is not in correct format.");
                    }
                    Console.WriteLine("Enter {0} Comma-Separated scores in the range of 0-100: ", len);
                    userInput = Console.ReadLine().Split(',');
                    Console.WriteLine("You entered:{0} scores", userInput.Length);
                    if (len != userInput.Length)
                    {
                        Console.WriteLine("You want to calculate {0} scores, " +
                                          "but you entered {1} scores", len, userInput.Length);
                    }
                } while (len != userInput.Length);
            }
            else
            {
                do
                {
                    Console.WriteLine("Enter Comma-Separated scores in the range of 0-100: ");
                    userInput = Console.ReadLine().Split(',');
                    Console.WriteLine("You entered:{0} scores", userInput.Length);
                } while (userInput.Length < 0);
            }



            AverageScore.InputValidation();
        }