using System.Collections.Generic;
public class StudentRecord : IComparable<StudentRecord>{
private Dictionary<string, string> dict;
public StudentRecord(string pname){
dict = new Dictionary<string, string>();
public void AddCourseResult(string Course, string Result){
public double CalculateGPA(){
Dictionary<string, string>.ValueCollection values = dict.Values;
foreach (string g in values){
foreach(KeyValuePair<string, string> pair in dict){
Console.WriteLine("Course = {0}, Grade = {1}", pair.Key, pair.Value);
public int CompareTo(StudentRecord s){
if (gpa > s.gpa) return -1;
else if (gpa == s.gpa) return 0;
public static void Main()
List<StudentRecord> SR = new List<StudentRecord>();
StudentRecord s1 = new StudentRecord("John");
StudentRecord s2 = new StudentRecord("Mary");
StudentRecord s3 = new StudentRecord("Joe");
StudentRecord s4 = new StudentRecord("Susie");
s1.AddCourseResult("IERG3080","B");
s1.AddCourseResult("IERG3300","A");
s2.AddCourseResult("IERG3080","A");
s2.AddCourseResult("IERG3300","A");
s2.AddCourseResult("GEEC1000","B");
s3.AddCourseResult("IERG3080","C");
s3.AddCourseResult("IERG3300","B");
s3.AddCourseResult("ACAT1001","C");
s4.AddCourseResult("CSCI2100","C");
s4.AddCourseResult("IERG2051","F");
Console.WriteLine("GPA = {0}",s1.GPA);
Console.WriteLine("GPA = {0}",s2.GPA);
Console.WriteLine("GPA = {0}",s3.GPA);
Console.WriteLine("GPA = {0}",s4.GPA);
foreach (StudentRecord x in SR){
Console.Write("{0} ",x.Name);