2021-02-16 22:34:31 +00:00
|
|
|
using System;
|
2021-02-16 22:27:58 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace GradeBook
|
|
|
|
{
|
|
|
|
class Book
|
|
|
|
{
|
|
|
|
private List<double> grades;
|
|
|
|
private string name;
|
|
|
|
|
|
|
|
public Book(string name)
|
|
|
|
{
|
|
|
|
this.name = name;
|
|
|
|
grades = new List<double>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void AddGrade(double grade)
|
|
|
|
{
|
|
|
|
this.grades.Add(grade);
|
|
|
|
}
|
2021-02-16 22:34:31 +00:00
|
|
|
|
|
|
|
public void ShowStaticstics()
|
|
|
|
{
|
|
|
|
|
|
|
|
double result = 0;
|
|
|
|
var highGrade = double.MinValue;
|
|
|
|
var lowGrade = double.MaxValue;
|
|
|
|
|
|
|
|
foreach (var number in this.grades)
|
|
|
|
{
|
|
|
|
highGrade = Math.Max(number, highGrade);
|
|
|
|
lowGrade = Math.Min(number, lowGrade);
|
|
|
|
result += number;
|
|
|
|
}
|
|
|
|
result /= grades.Count;
|
|
|
|
|
|
|
|
Console.WriteLine($"The average grade is {result:N1}");
|
|
|
|
Console.WriteLine($"The highest grade is {highGrade:N1}");
|
|
|
|
Console.WriteLine($"The lowest grade is {lowGrade:N1}");
|
|
|
|
}
|
2021-02-16 22:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|