Exemple #1
0
        public GradeStatistics ComputeStatistics()
        {
            GradeStatistics stats = new GradeStatistics();
            float           sum   = 0;

            foreach (float grade in grades)
            {
                if (grade > stats.HighestGrade) //Tambien se podria lanzar de la siguiente manera Math.Max(grade, stats.HighestGrade); mostraria el mas alto de las 2 variables
                {
                    stats.HighestGrade = grade;
                }
                stats.lowerstGrade = Math.Min(grade, stats.lowerstGrade);
                sum += grade;
            }
            stats.AverageGrade = sum / grades.Count;
            return(stats);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            //System.Speech.Synthesis.SpeechSynthesizer SYNTH = new System.Speech.Synthesis.SpeechSynthesizer(); //permite la lectura del comentario por voz
            //SYNTH.Speak("Hello! This is the grade book program Rocky");

            GradeBook book = new GradeBook();

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

            GradeBook book2 = book;

            book2.AddGrade(75);
            GradeStatistics stats = book.ComputeStatistics();

            Console.WriteLine("Promedio Medio " + stats.AverageGrade);
            Console.WriteLine("Grade Mas Alto " + stats.HighestGrade);
            Console.WriteLine("Grade mas pequeño " + stats.lowerstGrade);
        }