public int CalculateLettersAllInRange()
        {
            int CountLetters = 0;

            foreach (var item in SetupHelper.CreateWordDictionaryForOneToNineteen())
            {
                CountLetters = CountLetters + item.Value.Length;
            }
            return(CountLetters);
        }
Esempio n. 2
0
        public int CalculateLetters(int endrange)
        {
            int CountLetters   = 0;
            int Remainder      = 0;
            int DivisionResult = 0;

            if (endrange < 100)
            {
                CountLetters = TwentyToNintynineCalCulator.CalculateLetters(endrange);
            }
            else
            {
                Remainder      = endrange % 100;
                DivisionResult = endrange / 100;
                var LetterList         = SetupHelper.CreateWordDictionaryForOneToNineteen();
                var highestIndexInList = DivisionResult - 1;
                if (highestIndexInList > 0)
                {
                    for (int counter = 0; counter <= highestIndexInList; counter++)
                    {
                        CountLetters = CountLetters + TwentyToNintynineCalCulator.CalculateLetters(99);
                        if (counter < highestIndexInList)
                        {
                            CountLetters = CountLetters + (100 * (LetterList.ElementAt(counter).Value.Length));
                            CountLetters = CountLetters + (100 * HUNDRED.Length);
                            CountLetters = CountLetters + (99 * HUNDREDAND.Length);
                        }
                        else
                        {
                            CountLetters = CountLetters + ((Remainder + 1) * (LetterList.ElementAt(highestIndexInList).Value.Length));
                            CountLetters = CountLetters + ((Remainder + 1) * HUNDRED.Length);
                            CountLetters = CountLetters + (Remainder * HUNDREDAND.Length);
                            CountLetters = CountLetters + TwentyToNintynineCalCulator.CalculateLetters(Remainder);
                        }
                    }
                }
                else
                {
                    CountLetters = CountLetters + TwentyToNintynineCalCulator.CalculateLetters(99);
                    CountLetters = CountLetters + ((Remainder + 1) * (LetterList.ElementAt(highestIndexInList).Value.Length));
                    CountLetters = CountLetters + ((Remainder + 1) * HUNDRED.Length);
                    CountLetters = CountLetters + (Remainder * HUNDREDAND.Length);
                    CountLetters = CountLetters + TwentyToNintynineCalCulator.CalculateLetters(Remainder);
                }
            }

            return(CountLetters);
        }
        public int CalculateLetters(int endrange)
        {
            int CountLetters = 0;

            if (endrange > 0)
            {
                foreach (var item in SetupHelper.CreateWordDictionaryForOneToNineteen())
                {
                    if (endrange >= item.Key)
                    {
                        CountLetters = CountLetters + item.Value.Length;
                    }
                }
            }
            return(CountLetters);
        }
Esempio n. 4
0
        public int CalculateLetters(int endrange)
        {
            int CountLetters   = 0;
            int Remainder      = 0;
            int DivisionResult = 0;

            Remainder      = endrange % 10;
            DivisionResult = endrange / 10;
            if (DivisionResult <= 1)
            {
                CountLetters = OneToNineteenCalculator.CalculateLetters(endrange);
            }
            else
            {
                CountLetters = OneToNineteenCalculator.CalculateLettersAllInRange();
                var LetterList         = SetupHelper.CreateWordDictionaryForTens();
                var highestIndexInList = DivisionResult - 2;
                if (highestIndexInList > 0)
                {
                    for (int counter = 0; counter < highestIndexInList; counter++)
                    {
                        CountLetters = CountLetters + (10 * LetterList.ElementAt(counter).Value.Length);
                        CountLetters = CountLetters + OneToNineteenCalculator.CalculateLetters(9);
                    }

                    CountLetters = CountLetters + OneToNineteenCalculator.CalculateLetters(Remainder);
                    CountLetters = CountLetters + ((Remainder + 1) * LetterList.ElementAt(highestIndexInList).Value.Length);
                }
                else
                {
                    CountLetters = CountLetters + OneToNineteenCalculator.CalculateLetters(Remainder);
                    CountLetters = CountLetters + ((Remainder + 1) * LetterList.ElementAt(highestIndexInList).Value.Length);
                }
            }

            return(CountLetters);
        }