Beispiel #1
0
        public statistics getStatistics()
        {
            var result = new statistics(double.MinValue, double.MaxValue);

            // {
            //     average  = 0.0,
            //     high = double.MinValue,
            //     low = double.MaxValue
            // };

            // result.average  = 0.0;
            // result.high = double.MinValue;
            // result.low = double.MaxValue;

            // foreach(var grade in grades){

            //     result.high = Math.Max(grade,  result.high);
            //     result.low = Math.Min(grade, result.low );

            //     result.average += grade;
            // }
            //     result.average /= grades.Count;
            result.calculateAverage(grades);
            return(result);
        }
Beispiel #2
0
        public override statistics GetStatistics()
        {
            var result = new statistics();

            for (var index = 0; index < grades.Count; index += 1)
            {
                result.Add(grades[index]);
            }

            return(result);
        }
Beispiel #3
0
        public override statistics GetStatistics()
        {
            var result = new statistics();

            using (var reader = File.OpenText($"{Name}.txt"))
            {
                var line = reader.ReadLine();
                while (line != null)
                {
                    var number = double.Parse(line);
                    result.Add(number);
                    line = reader.ReadLine();
                }
            }
            return(result);
        }
Beispiel #4
0
        public statistics GetStatistics()
        {
            var result = new statistics();

            result.Average = 0.0;
            result.High    = double.MinValue;
            result.Low     = double.MaxValue;

            for (var index = 0; index < grades.Count; index += 1)

            {
                if (grades[index] == 42.1)
                {
                    continue;
                }
                result.Low      = Math.Min(grades[index], result.Low);
                result.High     = Math.Max(grades[index], result.High);
                result.Average += grades[index];
            }
            ;
            result.Average /= grades.Count;

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

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

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

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

            case var d when d >= 50.0:
                result.Letter = 'F';
                break;
            }
            return(result);
        }
Beispiel #5
0
        public statistics GetStats()
        {
            var result = new statistics();

            result.Average = 0.0;
            result.High    = double.MinValue;
            result.Low     = double.MaxValue;
            foreach (var grade in grades)
            {
                result.High     = Math.Max(grade, result.High);
                result.Low      = Math.Min(grade, result.Low);
                result.Average += grade;
            }
            result.Average /= grades.Count;

            return(result);
        }
Beispiel #6
0
        //line below used to be public void getStatistics(), removed the void in order to make it available for other namespaces
        //line below could of been public int getStatistic(), it would allow for a value to be return. However I am not interested in int
        //or string, i want an type 'object' called statistics. View statistics.cs for more details
        public statistics getStatistics()
        {
            var result = new statistics();

            result.average = 0.0;
            result.high    = double.MinValue;
            result.low     = double.MaxValue;

            foreach (double grade in grades)
            {
                result.high    = Math.Max(grade, result.high);
                result.low     = Math.Min(grade, result.low);
                result.average = result.average + grade;
            }
            result.average = result.average / grades.Count;
            return(result);
        }
Beispiel #7
0
        public override statistics GetStatistics()
        {
            var result = new statistics();

            result.Average = 0.0;
            result.High    = double.MinValue;
            result.Low     = double.MaxValue;

            var index = 0;

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

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

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

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

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

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

            return(result);
        }