using System.Collections.Generic;
public class StudentRecord: IComparable<StudentRecord>{
Dictionary<string, string> scores;
static Dictionary<string, double> gradeToGPA = new Dictionary<string, double>(){
{"A", 4.0} , {"B", 3.3}, {"C", 2.7}, {"F", 0}
public StudentRecord(string pName){
scores = new Dictionary<string, string>();
public void AddCourse(string pCourse, string pGrade){
scores.Add(pCourse, pGrade);
public double CalculateGPA(){
foreach(KeyValuePair<string, string> pair in scores)
sumGPA += gradeToGPA[scores[pair.Key]];
cGPA = sumGPA / courseCount;
public int CompareTo(StudentRecord s){
if (cGPA > s.cGPA) return 1;
else if ( Math.Abs(cGPA - s.cGPA) < e ) return 0;
public override string ToString(){
public static void Main()
StudentRecord john = new StudentRecord("John");
john.AddCourse("IERG3080", "B");
john.AddCourse("IERG3300", "A");
StudentRecord mary = new StudentRecord("Mary");
mary.AddCourse("IERG3080", "A");
mary.AddCourse("IERG3300", "A");
StudentRecord joe = new StudentRecord("Joe");
joe.AddCourse("IERG3080", "C");
joe.AddCourse("IERG3300", "B");
joe.AddCourse("ACAT1001", "C");
StudentRecord susie = new StudentRecord("Susie");
susie.AddCourse("CSCI2100", "C");
susie.AddCourse("IERG2051", "F");
List<StudentRecord> studentList = new List<StudentRecord>();
foreach(StudentRecord s in studentList)
Console.WriteLine("{0}'s GPA is {1}", s, s.CGPA);