Пример #1
0
        public Gstats ComputeStatistics()
        {
            Gstats stats = new Gstats();
            float  sum   = 0;

            foreach (float grade in grades)
            {
                stats.HighestGrade = Math.Max(grade, stats.HighestGrade);
                stats.LowestGrade  = Math.Min(grade, stats.LowestGrade);
                sum += grade;
            }
            stats.AverageGrade = sum / grades.Count;
            return(stats);
        }
Пример #2
0
        static void Main(string[] args)
        {
            BookOfGrades book1 = new BookOfGrades();


            book1.Name = "Brooklyn's book of grades";

            book1.AddGrade(67);
            book1.AddGrade(57);
            book1.AddGrade(63);
            book1.AddGrade(61);
            book1.AddGrade(77);
            book1.AddGrade(47);
            book1.AddGrade(60);
            book1.AddGrade(2);
            book1.AddGrade(7);
            book1.AddGrade(6);
            book1.AddGrade(16);
            book1.AddGrade(23);
            book1.AddGrade(57);
            book1.AddGrade(38);
            book1.AddGrade(94);
            book1.AddGrade(69);
            book1.AddGrade(99);
            book1.AddGrade(12);
            book1.AddGrade(17);
            book1.AddGrade(87);
            CurrentGrades(book1.NumOfGrades());

            Gstats stats = book1.ComputeStatistics();

            Console.WriteLine(book1.Name);
            WriteResult("Average", stats.AverageGrade);
            WriteResult("Highest", stats.HighestGrade);
            WriteResult("Lowest", stats.LowestGrade);
        }