コード例 #1
0
        public GradeBookStatistics ComputeStatistics()
        {
            GradeBookStatistics stats = new GradeBookStatistics();


            float sum = 0;

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



                //if (grade > stats.HighestGrade)
                //    stats.HighestGrade = grade;

                sum += grade;
            }
            stats.AverageGrade = sum / grades.Count;

            return(stats);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            GradeBook book = new GradeBook();

            book.AddGrade(91);                          //----style debugg---run to cursor ctrl+F10---//
            book.AddGrade(89.5f);
            book.AddGrade(75);


            /* GradeBook book2 = new GradeBook(); */


            //GradeBook book2 = book;
            //book2.AddGreat(75);
            GradeBookStatistics stats = book.ComputeStatistics();

            Console.WriteLine(stats.AverageGrade);
            Console.WriteLine(stats.LowestGrade);
            Console.WriteLine(stats.HighestGrade);

            SpeechSynthesizer synth = new SpeechSynthesizer();

            synth.Speak("Forza Ferrari");
        }