diff --git a/gradebook/src/GradeBook/Book.cs b/gradebook/src/GradeBook/Book.cs new file mode 100644 index 0000000..911cc88 --- /dev/null +++ b/gradebook/src/GradeBook/Book.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; + +namespace GradeBook +{ + class Book + { + private List grades; + private string name; + + public Book(string name) + { + this.name = name; + grades = new List(); + } + + public void AddGrade(double grade) + { + this.grades.Add(grade); + } + } + +} \ No newline at end of file diff --git a/gradebook/src/GradeBook/Program.cs b/gradebook/src/GradeBook/Program.cs index f4b443d..3682124 100644 --- a/gradebook/src/GradeBook/Program.cs +++ b/gradebook/src/GradeBook/Program.cs @@ -7,24 +7,29 @@ namespace GradeBook { static void Main(string[] args) { + + var book = new Book("Scott's Grade Book"); + book.AddGrade(89.1); + book.AddGrade(90.5); + List grades = new List() {12.7, 10.3, 6.11, 4.1}; grades.Add(56.1); double result = 0; + var highGrade = double.MinValue; + var lowGrade = double.MaxValue; foreach (var number in grades) { + highGrade = Math.Max(number, highGrade); + lowGrade = Math.Min(number, lowGrade); + result += number; } result /= grades.Count; - System.Console.WriteLine($"The average grade is {result}"); - - if (args.Length > 0) - { - Console.WriteLine($"Hello, {args[0]}!"); - } else{ - Console.WriteLine("Where is the name?"); - } + Console.WriteLine($"The average grade is {result:N1}"); + Console.WriteLine($"The highest grade is {highGrade:N1}"); + Console.WriteLine($"The lowest grade is {lowGrade:N1}"); } } }