Last active
June 15, 2016 05:45
-
-
Save 5st7/9116cf7e80cb2554e43205843e40198d to your computer and use it in GitHub Desktop.
06/15日のC#勉強会で出した課題の解答例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using CampusSquare; | |
class Example1 | |
{ | |
static void Main(string[] args) | |
{ | |
var grades = new CampusSquare.DummyCampusSquare("record.html").GetGrades(); | |
double creditSum = 0, gradeSum = 0; | |
foreach (IGrade grade in grades) | |
{ | |
creditSum += grade.CreditNum; | |
gradeSum += grade.CreditNum * grade.GradeNum; | |
} | |
double gpa = gradeSum / creditSum; | |
Console.WriteLine("GPA:\t{0}", gpa); | |
int max = 0, min = 4; | |
foreach (IGrade grade in grades) | |
{ | |
max = Math.Max(max, grade.GradeNum); | |
min = Math.Min(min, grade.GradeNum); | |
} | |
Console.WriteLine("\ngood:"); | |
foreach (IGrade grade in grades) | |
{ | |
if (grade.GradeNum == max) | |
{ | |
Console.WriteLine("\t{0}:{1}", grade.Grade, grade.Name); | |
} | |
} | |
Console.WriteLine("\nbad:"); | |
foreach (IGrade grade in grades) | |
{ | |
if (grade.GradeNum == min) | |
{ | |
Console.WriteLine("\t{0}:{1}", grade.Grade, grade.Name); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment