public void ShowStatistic() { ThanhPhan ThanhPhan = TinhToanDiem(); Console.WriteLine("Cao nhat: {0}", ThanhPhan.CaoNhat); Console.WriteLine("Thap nhat: {0}", ThanhPhan.ThapNhat); Console.WriteLine("Trung binh: {0}", ThanhPhan.TrungBinh); }
public ThanhPhan TinhToanDiem() { ThanhPhan ThanhPhan = new ThanhPhan(); float Tong = 0; foreach (float diemso in DanhSachDiem) { ThanhPhan.CaoNhat = Math.Max(diemso, ThanhPhan.CaoNhat); ThanhPhan.ThapNhat = Math.Min(diemso, ThanhPhan.ThapNhat); Tong += diemso; } ThanhPhan.TrungBinh = (DanhSachDiem.Count() > 0) ? Tong / DanhSachDiem.Count() : 0; return(ThanhPhan); }