Finished Module 2. Learning the C# Syntax

jason.zhu 2021-02-16 04:07:37 +00:00
parent 0d8548d380
commit 4fe8c1f2bb
1 changed files with 6 additions and 3 deletions

View File

@ -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<double> grades = new List<double>() {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)
{