Beispiel #1
0
        private static void WriteResults(GradeBook book)
        {
            SaveGrades(book);

            GradeSatistics stats = book.ComputeStatistics();

            WriteResult("Average", stats.AverageGrade);
            WriteResult("Highest", stats.HighestGrade);
            WriteResult("Lowest", stats.LowestGrade);
            WriteResult(stats.Description, stats.LetterGrade);
        }
Beispiel #2
0
        public GradeSatistics ComputeStatistics()
        {
            GradeSatistics stats = new GradeSatistics();


            float sum = 0;

            foreach (float grade in grades)
            {
                //if (grade > stats.HighestGrade) stats.HighestGrade = grade;
                //if (grade < stats.LowestGrade) stats.LowestGrade = grade;

                stats.HighestGrade = Math.Max(grade, stats.HighestGrade);
                stats.LowestGrade  = Math.Min(grade, stats.LowestGrade);

                sum += grade;
            }
            stats.AverageGrade = sum / grades.Count;

            return(stats);
        }