コード例 #1
0
        //Ask about a TRY CATCH or another way to limit inputs
        //Unlimited grades
        public (double average, string letterGrade) HotelCalifornia()
        {
            Class1 class1 = new Class1();

            bool complete = true;
            // use the count to provide the value for my average
            int    count = -1;
            int    index = 1;
            double grade = 0;

            do
            {
                Console.Clear();

                Console.WriteLine("Welcome to Hotel California \n.....\n.....We've checked you in.");
                Console.WriteLine($"\nType the word \"Complete\" to exit");
                Console.Write($"\nPlease enter grade #{index}: ");
                var input = Console.ReadLine();

                if (input == "Complete")
                {
                    complete = false;
                }
                else
                {
                    grade = grade + Convert.ToInt32(input);
                }
                index++;
                count++;
            } while (complete);
            double average     = grade / count;
            string letterGrade = class1.LetterGrade(average);

            Console.WriteLine($"Your student's average is {Math.Round(average, 2) / 100:P} which earns them the lettergrade of {letterGrade}");

            return(average, letterGrade);
        }
コード例 #2
0
        // Average ten scores
        public double MostPeopleAreHere()
        {
            Console.WriteLine("Top Ten Average!!");
            Console.WriteLine("\nHit Enter to continue...");
            Class1 class1 = new Class1();

            Console.ReadLine();
            double value   = class1.Addition(10);
            double average = value / 10;

            Console.ReadLine();
            Console.Clear();
            Console.WriteLine($"Your student's average is {class1.Average(value, 10) / 100:P} resulting in a {class1.LetterGrade(average)}");
            return(class1.Average(value, 10));
        }
コード例 #3
0
        //Average specific number of scores.
        public double TheGradesAreFixed()
        {
            Class1 class1 = new Class1();

            Console.WriteLine("The Grades are fixed and the results don't matter\n\nMostly...");
            Console.WriteLine("\nHit Enter to continue...");

            Console.ReadLine();
            Console.Write("How many Grades do you have to enter?: ");
            double count   = double.Parse(Console.ReadLine());
            double value   = class1.Addition(count);
            double average = value / count;

            Console.ReadLine();
            Console.Clear();
            Console.WriteLine($"Your student's average is {class1.Average(value, 10) / 100:P} resulting in a {class1.LetterGrade(average)}");
            return(class1.Average(value, count));
        }