예제 #1
0
        static void Main(string[] args)
        {
            SpeechSynthesizer synth = new SpeechSynthesizer();

            synth.Speak("hello! This is a grade book program");

            Gradebook book = new Gradebook();

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

            Gradestatistics stats = book.ComputeStatistics();

            synth.Speak("The average grade in the grade book was");

            WriteResult("Average", stats.AverageGrade);

            synth.Speak("The Highest overall grade was");

            WriteResult("Highest", stats.HighestGrade);

            synth.Speak("The lowest overall grade was");
            WriteResult("Lowest", stats.LowestGrade);

            synth.Speak("Please press any key to continue, Thank you");
            Console.WriteLine("the rain falls during storms");

            Gradebook book2 = new Gradebook();

            book2.AddGrade(18);
            book2.AddGrade(78);

            Gradestatistics info = book2.ComputeStatistics();
        }
예제 #2
0
        public Gradestatistics ComputeStatistics()
        {
            Gradestatistics stats = new Gradestatistics();


            float sum = 0;

            foreach (float grade in grades)
            {
                stats.HighestGrade = Math.Max(grade, stats.HighestGrade);
                stats.LowestGrade  = Math.Min(grade, stats.LowestGrade);
                sum = sum + grade;
            }

            stats.AverageGrade = sum / grades.Count;

            return(stats);
        }