Example #1
0
 private static void ComputeStatisticsAndOutputStats(GradeBook grades)
 {
     GradeStatistics stats = new GradeStatistics();
     stats = grades.ComputeStatics();
     WriteResults("Average", stats.averageGrade);
     WriteResults("Higest", stats.highestGrade);
     WriteResults("Lowest", stats.lowestGrade);
     WriteResults("Grade", stats.LetterGrade);
     WriteResults("Description:", stats.GradeDescription);
 }
Example #2
0
        public virtual GradeStatistics ComputeStatics()
        {
            var stats = new GradeStatistics();

            float sum = 0;
            foreach (var grade in grades)
            {
                stats.highestGrade = Math.Max(stats.highestGrade, grade);
                stats.lowestGrade = Math.Min(stats.lowestGrade, grade);
                sum += grade;
            }
            stats.averageGrade = sum / grades.Count;
            return stats;
        }