diff --git a/gradebook/src/GradeBook/Book.cs b/gradebook/src/GradeBook/Book.cs index d75d2c2..3c8262a 100644 --- a/gradebook/src/GradeBook/Book.cs +++ b/gradebook/src/GradeBook/Book.cs @@ -26,12 +26,21 @@ namespace GradeBook result.highGrade = double.MinValue; result.lowGrade = double.MaxValue; - foreach (var grade in this.grades) + // foreach (var grade in this.grades) + // { + // result.lowGrade = Math.Min(grade, result.lowGrade); + // result.highGrade = Math.Max(grade, result.highGrade); + // result.Average += grade; + // } + + var index = 0; + do { - result.lowGrade = Math.Min(grade, result.lowGrade); - result.highGrade = Math.Max(grade, result.highGrade); - result.Average += grade; - } + result.lowGrade = Math.Min(grades[index], result.lowGrade); + result.highGrade = Math.Max(grades[index], result.highGrade); + result.Average += grades[index]; + index += 1; + } while (index < grades.Count); result.Average /= grades.Count; return result;