From 4fe8c1f2bbb0e247c8d99bf2be7a5bc80a228aa1 Mon Sep 17 00:00:00 2001 From: "jason.zhu" Date: Tue, 16 Feb 2021 04:07:37 +0000 Subject: [PATCH] Finished Module 2. Learning the C# Syntax --- gradebook/src/GradeBook/Program.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gradebook/src/GradeBook/Program.cs b/gradebook/src/GradeBook/Program.cs index a4a009d..f4b443d 100644 --- a/gradebook/src/GradeBook/Program.cs +++ b/gradebook/src/GradeBook/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace GradeBook { @@ -6,15 +7,17 @@ namespace GradeBook { static void Main(string[] args) { - var numbers = new[] {12.7, 10.3, 1.1}; + List grades = new List() {12.7, 10.3, 6.11, 4.1}; + grades.Add(56.1); double result = 0; - foreach (var number in numbers) + foreach (var number in grades) { result += number; } + result /= grades.Count; - System.Console.WriteLine(result); + System.Console.WriteLine($"The average grade is {result}"); if (args.Length > 0) {