Ejemplo n.º 1
0
        public Statistics GetStatistics()
        {
            if (Grades.Equals(null))
            {
                this.ListGrades();
                Console.WriteLine("Yeah, things were null!");
                return(null);
            }
            else
            {
                var total = new Statistics();
                total.High = double.MinValue;
                total.Low  = double.MaxValue;
                total.Sum  = 0;


                for (var index = 0; index < Grades.Count; index++)
                {
                    if (Grades[index] == 98.6)
                    {
                        // break;
                        // continue;
                        // goto done;
                    }
                    total.High = Math.Max(Grades[index], total.High);
                    total.Low  = Math.Min(Grades[index], total.Low);
                    total.Sum += Grades[index];
                }
                ;
                // var index = 0;
                // while(index < Grades.Count)
                // {
                //   total.High = Math.Max(Grades[index], total.High);
                //   total.Low = Math.Min(Grades[index], total.Low);
                //   total.Sum += Grades[index];
                //   index+=1;
                // };
                // foreach (var grade in Grades)
                // {
                //   total.High = Math.Max(grade, total.High);
                //   total.Low = Math.Min(grade, total.Low);
                //   total.Sum += grade;
                // }

                total.Average = total.Sum / Grades.Count;

                switch (total.Average)
                {
                case var d when d >= 90.0:
                    total.Letter = 'A';
                    break;

                case var d when d >= 80.0:
                    total.Letter = 'B';
                    break;

                case var d when d >= 70.0:
                    total.Letter = 'C';
                    break;

                case var d when d >= 60.0:
                    total.Letter = 'D';
                    break;

                default:
                    total.Letter = 'F';
                    break;
                }

                return(total);
            }
        }
Ejemplo n.º 2
0
        public Statistics GetStatistics()
        {
            var stats = new Statistics();

            stats.Average = GetAverage();
            stats.High    = GetMax();
            stats.Low     = GetMin();

            // var stats = new Statistics();
            // stats.Average = 0.0;
            // stats.High = double.MinValue;
            // stats.Low = double.MaxValue;

            // foreach (double grade in grades)
            // {
            //     stats.Low = Math.Min(grade, stats.Low);
            //     stats.High = Math.Max(grade, stats.High);
            //     stats.Average += grade;
            // }
            // stats.Average /= grades.Count;

            // for (int index = 0; index < grades.Count; index++)
            // {
            //     stats.Low = Math.Min(grades[index], stats.Low);
            //     stats.High = Math.Max(grades[index], stats.High);
            //     stats.Average += grades[index];
            // }
            // stats.Average /= grades.Count;

            // int index = 0;
            // while (index < grades.Count)
            // {
            //     stats.Low = Math.Min(grades[index], stats.Low);
            //     stats.High = Math.Max(grades[index], stats.High);
            //     stats.Average += grades[index];
            //     index++;
            // };
            // stats.Average /= grades.Count;

            // int index = 0;
            // do
            // {
            //     stats.Low = Math.Min(grades[index], stats.Low);
            //     stats.High = Math.Max(grades[index], stats.High);
            //     stats.Average += grades[index];
            //     index++;
            // } while (index < grades.Count);
            // stats.Average /= grades.Count;

            switch (stats.Average)
            {
            case var average when average >= 95.0:
                stats.Letter = "A+";
                break;

            case var average when average >= 90.0:
                stats.Letter = "A";
                break;

            case var average when average >= 80.0:
                stats.Letter = "B";
                break;

            case var average when average >= 70.0:
                stats.Letter = "C";
                break;

            case var average when average >= 60.0:
                stats.Letter = "D";
                break;

            default:
                stats.Letter = "F";
                break;
            }

            return(stats);
        }
Ejemplo n.º 3
0
        public override Statistics GetStatistics()
        {
            var stats = new Statistics(_grades);

            return(stats);
        }
        public override Statistics GetStatistics()
        {
            Statistics result = new Statistics(this.Grades);

            return(result);
        }