public double GetGPAForGrade(double grade)
        {
            GradeScale[] gradeScales;

            //if they have a custom grade scale
            if (this.GradeScales != null && this.GradeScales.Length != 0)
            {
                gradeScales = this.GradeScales;
            }


            //use default grade scale
            else
            {
                gradeScales = GradeScale.GenerateDefaultScaleWithoutLetters();
            }



            //if the grade percents are rounded up
            if (this.DoesRoundGradesUp)
            {
                int roundedGrade = (int)MyMath.Round(grade * 100);

                for (int i = 0; i < gradeScales.Length; i++)
                {
                    if (roundedGrade >= (gradeScales[i]).StartGrade)
                    {
                        return((gradeScales[i]).GPA);
                    }
                }
            }

            else
            {
                for (int i = 0; i < gradeScales.Length; i++)
                {
                    if (grade * 100 >= (gradeScales[i]).StartGrade)
                    {
                        return((gradeScales[i]).GPA);
                    }
                }
            }

            return(gradeScales.Last().GPA);
        }
        protected override void PopulateFromDataItemOverride(BaseDataItem dataItem)
        {
            base.PopulateFromDataItemOverride(dataItem);

            DataItemClass i = dataItem as DataItemClass;

            CourseNumber             = i.CourseNumber;
            ShouldAverageGradeTotals = i.ShouldAverageGradeTotals;
            DoesRoundGradesUp        = i.DoesRoundGradesUp;
            Color        = i.RawColor;
            Position     = i.Position;
            GradeScales  = i.GetGradeScales() ?? GradeScale.GenerateDefaultScaleWithoutLetters();
            Credits      = i.Credits;
            StartDate    = DateTime.SpecifyKind(i.StartDate, DateTimeKind.Local);
            EndDate      = DateTime.SpecifyKind(i.EndDate, DateTimeKind.Local);
            GpaType      = i.GpaType;
            PassingGrade = i.PassingGrade;

            _needsRecalc = true;
        }
        private async System.Threading.Tasks.Task ReloadSavedGradeScalesPicker()
        {
            var account            = MainScreenViewModel.CurrentAccount;
            var savedScalesManager = await SavedGradeScalesManager.GetForAccountAsync(account);

            var savedScales = await savedScalesManager.GetSavedGradeScalesAsync();

            if (!savedScales.Any(i => i.Name.Equals("United States")))
            {
                savedScales.Add(new SavedGradeScale()
                {
                    Name        = "United States",
                    GradeScales = GradeScale.GenerateDefaultScaleWithoutLetters()
                });
            }

            if (!savedScales.Any(i => i.Name.Equals("Eleven-Point System")))
            {
                savedScales.Add(new SavedGradeScale()
                {
                    Name        = "Eleven-Point System",
                    GradeScales = GradeScale.GenerateElevenPointScale()
                });
            }

            if (!savedScales.Any(i => i.Name.Equals("Twelve-Point System")))
            {
                savedScales.Add(new SavedGradeScale()
                {
                    Name        = "Twelve-Point System",
                    GradeScales = GradeScale.GenerateTwelvePointScale()
                });
            }

            if (!savedScales.Any(i => i.Name.Equals("Mexico - 100 Point")))
            {
                savedScales.Add(new SavedGradeScale()
                {
                    Name        = "Mexico - 100 Point",
                    GradeScales = GradeScale.GenerateMexico100PointScale()
                });
            }

            if (!savedScales.Any(i => i.Name.Equals("Mexico - 10 Point")))
            {
                savedScales.Add(new SavedGradeScale()
                {
                    Name        = "Mexico - 10 Point",
                    GradeScales = GradeScale.GenerateMexico10PointScale()
                });
            }

            savedScales.Add(new SavedGradeScale()
            {
                Name = PowerPlannerResources.GetString("String_GradeScaleCustom")
            });

            SavedGradeScales = savedScales;

            UpdateSelectedSavedGradeScale();
        }