static void Main(string[] args) { GradeBook book = new GradeBook(); book.AddGrade(91); book.AddGrade(89.1f); book.AddGrade(75); GradeStats stats = book.ComputeStats(); Console.WriteLine(stats.AverageGrade); Console.WriteLine(stats.HighestGrade); Console.WriteLine(stats.LowestGrade); }
private static void PrintStats(IGradeinterface bookTwo) { GradeStats gs = new GradeStats(bookTwo); Console.WriteLine("List of the grades in " + bookTwo + ":"); //bookTwo = bookOne; gs.ComputeStats(); Console.WriteLine("Sum of the grades = " + gs.SumGrade); Console.WriteLine("Avg of the grades = " + gs.AverageGrade); Console.WriteLine("Max of the grades = " + gs.MaxGrade); Console.WriteLine("Min of the grades = " + gs.MinGrade); Console.WriteLine("Grade Letter is :" + gs.LetterGrade); }
public GradeStats GradeStats() { GradeStats stats = new GradeStats(); float sum = 0f; foreach(float grade in grades) { stats.HighGrade = Math.Max(grade, stats.HighGrade); stats.LowGrade = Math.Min(grade, stats.LowGrade); sum = sum + grade; } stats.AvGrade = sum / grades.Count; return stats; }
public GradeStats ComputeStats() { GradeStats stats = new GradeStats(); 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); }
static void Main(string[] args) { GradeBook book = new GradeBook(); book.NameChanged += OnNameChanged; book.Name = "Wilson's grade book"; book.Name = "Wilson's book"; book.AddGrade(95); book.AddGrade(89.1f); book.AddGrade(59); GradeStats stats = book.ComputeStats(); Console.WriteLine(book.Name); Console.WriteLine(stats.AverageGrade); Console.WriteLine(stats.HighestGrade); Console.WriteLine(stats.LowestGrade); }
public override GradeStats ComputeStats() { GradeStats stats = new GradeStats(); float sum = 0f; foreach (var grade in _Grades) { stats.HighestGrade = Math.Max(grade, stats.HighestGrade); stats.LowestGrade = Math.Min(grade, stats.LowestGrade); //sum = sum + grade sum += grade; } stats.AverageGrade = sum / _Grades.Count; return stats; }