コード例 #1
0
ファイル: Program.cs プロジェクト: Longsh4nks/Grades
        static void Main(string[] args)
        {
            GradeBook book = new GradeBook();

            book.AddGrade(91);
            book.AddGrade(89.1f);
            book.AddGrade(75);

            GradeStats stats = book.ComputeStats();

            Console.WriteLine(stats.AverageGrade);
            Console.WriteLine(stats.HighestGrade);
            Console.WriteLine(stats.LowestGrade);
        }
コード例 #2
0
        private static void PrintStats(IGradeinterface bookTwo)
        {
            GradeStats gs = new GradeStats(bookTwo);

            Console.WriteLine("List of the grades in " + bookTwo + ":");
            //bookTwo = bookOne;
            gs.ComputeStats();

            Console.WriteLine("Sum of the grades = " + gs.SumGrade);
            Console.WriteLine("Avg of the grades = " + gs.AverageGrade);
            Console.WriteLine("Max of the grades = " + gs.MaxGrade);
            Console.WriteLine("Min of the grades = " + gs.MinGrade);
            Console.WriteLine("Grade Letter is :" + gs.LetterGrade);
        }
コード例 #3
0
        public GradeStats GradeStats()
        {
            GradeStats stats = new GradeStats();
            float sum = 0f;

            foreach(float grade in grades)
            {
                stats.HighGrade = Math.Max(grade, stats.HighGrade);
                stats.LowGrade = Math.Min(grade, stats.LowGrade);
                sum = sum + grade;
            }
            stats.AvGrade = sum / grades.Count;
            return stats;
        }
コード例 #4
0
ファイル: GradeBook.cs プロジェクト: greenlegend20/hello_cs
        public GradeStats ComputeStats()
        {
            GradeStats stats = new GradeStats();

            float sum = 0;

            foreach (float grade in grades)
            {
                stats.HighestGrade = Math.Max(grade, stats.HighestGrade);
                stats.LowestGrade  = Math.Min(grade, stats.LowestGrade);
                sum += grade;
            }
            stats.AverageGrade = sum / grades.Count;
            return(stats);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            GradeBook book = new GradeBook();

            book.NameChanged += OnNameChanged;

            book.Name = "Wilson's grade book";
            book.Name = "Wilson's book";
            book.AddGrade(95);
            book.AddGrade(89.1f);
            book.AddGrade(59);
            GradeStats stats = book.ComputeStats();

            Console.WriteLine(book.Name);
            Console.WriteLine(stats.AverageGrade);
            Console.WriteLine(stats.HighestGrade);
            Console.WriteLine(stats.LowestGrade);
        }
コード例 #6
0
ファイル: GradeBook.cs プロジェクト: iimrankhan/PSSA
        public override GradeStats ComputeStats()
        {
            GradeStats stats = new GradeStats();

            float sum = 0f;

            foreach (var grade in _Grades)
            {
                stats.HighestGrade = Math.Max(grade, stats.HighestGrade);
                stats.LowestGrade = Math.Min(grade, stats.LowestGrade);

                //sum = sum + grade
                sum += grade;
            }

            stats.AverageGrade = sum / _Grades.Count;

            return stats;
        }