using System.Collections.Generic;
public Record(string course, string grade)
this.grade = "4.0".ToString();
this.grade = "3.3".ToString();
this.grade = "2.7".ToString();
this.grade = "0.0".ToString();
public class StudentRecord : IComparable<StudentRecord>
private double last_grade = 0;
private List<Record> courses = new List<Record>();
public void Add(Record re)
GPA = (last_grade + Convert.ToDouble(re.grade)) / count;
GPA = (last_grade * (count - 1) + Convert.ToDouble(re.grade)) / count;
public int CompareTo(StudentRecord other)
if (this.GPA >= other.GPA)
else if (this.GPA == other.GPA)
public override string ToString()
public static void Main()
List<StudentRecord> SList = new List<StudentRecord>();
StudentRecord John = new StudentRecord();
John.Add(new Record("IERG3080", "B"));
John.Add(new Record("IERG3300", "A"));
Console.WriteLine("John GPA :{0}", John.gpa);
StudentRecord Mary = new StudentRecord();
Mary.Add(new Record("IERG3080", "A"));
Mary.Add(new Record("IERG3300", "A"));
Mary.Add(new Record("GEEC1000", "B"));
Console.WriteLine("Mary GPA :{0}", Mary.gpa);
StudentRecord Joe = new StudentRecord();
Joe.Add(new Record("IERG3080", "C"));
Joe.Add(new Record("IERG3300", "B"));
Joe.Add(new Record("ACAT1001", "C"));
Console.WriteLine("Joe GPA :{0}", Joe.gpa);
StudentRecord Susie = new StudentRecord();
Susie.Add(new Record("CSCI2100", "C"));
Susie.Add(new Record("IERG2051", "F"));
Console.WriteLine("Susie GPA :{0}", Susie.gpa);
foreach (object GPA in SList)
Console.WriteLine("GPA = {0}", GPA);