示例#1
0
        public static string Ten(string ten)
        {
            if (ten[0] == '1')
            {
                if (ten.EndsWith("1"))
                {
                    return("eleven");
                }
                if (ten.EndsWith("2"))
                {
                    return("twleve");
                }

                if (ten.EndsWith("3"))
                {
                    return("Thirteen");
                }

                if (ten.EndsWith("4"))
                {
                    return("Fourteen");
                }

                if (ten.EndsWith("5"))
                {
                    return("Fifteen");
                }

                if (ten.EndsWith("6"))
                {
                    return("Fifteen");
                }

                if (ten.EndsWith("7"))
                {
                    return("Seventeen");
                }

                if (ten.EndsWith("8"))
                {
                    return("Eighteen");
                }

                if (ten.EndsWith("9"))
                {
                    return("nineteen");
                }
                if (ten.EndsWith("0"))
                {
                    return("Ten");
                }
                else
                {
                    return(" an Invalid input");
                }
            }
            //if (ten[0] == '2')
            if (true)
            {
                string tenth;

                if (ten[1] != '0')
                {
                    tenth = Units.Unit(ten[1]);
                }
                else
                {
                    tenth = "";
                }


                var x = ten[0];

                switch (x)
                {
                case '2':

                    return("Twenty " + tenth);

                    break;

                case '3':

                    return("Thirty " + tenth);

                    break;

                case '4':

                    return("Fourty " + tenth);

                    break;

                case '5':

                    return("Fifty " + tenth);

                    break;

                case '6':

                    return("Sixty " + tenth);

                    break;

                case '7':

                    return("Seventy " + tenth);

                    break;

                case '8':

                    return("Eighty " + tenth);

                    break;

                case '9':

                    return("Ninty " + tenth);

                    break;

                case '0':

                    return(tenth);

                    break;

                default:
                    Console.WriteLine("You entered an invalid input");
                    return("Invalid");

                    break;
                }
            }
            return("Testing");
        }
示例#2
0
        static void Main(string[] args)
        {
Start:
            //  string isaac = Console.ReadLine();

            //  Console.WriteLine(isaac.Length);


            //number to convert to text
            SpeechSynthesizer synth = new SpeechSynthesizer();

            synth.Speak("Enter an input");

            //do
            //{

            //} while (b);

            Console.WriteLine("PLEASE ENTER A NUMBER THAT THE COMPUTER WILL CONVERT TO A STRING AUTOMATICALLY");

            Console.WriteLine("The maximum number you can enter is 1 billion");
            string input = Console.ReadLine();

            //string input = ("78");



            //test to check the length of the input
            if (input.Length == 1)
            {
                string result = Units.Unit(input[0]);
                Console.WriteLine("You entered {0}", result);
                synth.Speak(result);
            }

            else if (input.Length == 2)
            {
                string result = Tens.Ten(input);
                Console.WriteLine("You entered {0}", result);
                synth.Speak(result);
            }

            else if (input.Length == 3)
            {
                string result = Hundreds.Hundred(input);
                Console.WriteLine("You entered {0}", result);
                synth.Speak(result);
            }

            else if (input.Length >= 4 && input.Length <= 6)
            {
                string result = Thousands.Thousand(input);
                Console.WriteLine("You entered {0}", result);
                //synth.Speak(result);
            }

            else if (input.Length >= 7 && input.Length <= 9)
            {
                string result = Million.Millions(input);
                Console.WriteLine("You entered {0}", result);
                //synth.Speak(result);
            }

            else if (input == "10000000000")
            {
                Console.WriteLine("You entered 1 billion ");
            }
            else
            {
                Console.WriteLine("the number is above the expected range, The max number is 1billion");
            }

            goto Start;


            //else if (input.Length == 5)
            //{
            //    string result = TenThousand.TenThousands(input);
            //    Console.WriteLine("You entered {0}", result);
            //    //synth.Speak(result);
            //}
        }
示例#3
0
        public static string Hundred(string hundred)
        {
            var tens = hundred.Substring(1);

            string tenth = String.Empty;
            string and;

            if (tens != "00")
            {
                and = " and ";
            }
            else
            {
                and = String.Empty;
            }

            /*This checks if the tens unit in the hundred is zero or not, if it is it simple takes the last
             * digit and pass it to the unit method in the units class, else it calls the tens class with the last two digit(tens part)*/
            if (tens[0] != '0')
            {
                //if tens != '00'
                tenth = Tens.Ten(tens);
            }
            else
            {
                /* this would always run when the first number in the hundred is zero and also
                 * when the last number is not zero(anything else but zero)*/
                if (hundred[0] == '0' || tens[1] != '0')
                {
                    tenth = Units.Unit(tens[1]);
                }
            }



            var x = hundred[0];


            switch (x)
            {
            case '1':

                return("One Hundred" + and + tenth);

                break;

            case '2':

                return("Two Hundred" + and + tenth);

                break;

            case '3':

                return("Three Hundred" + and + tenth);

                break;

            case '4':

                return("Four Hundred" + and + tenth);

                break;

            case '5':

                return("five Hundred" + and + tenth);

                break;

            case '6':

                return("Six Hundred" + and + tenth);

                break;

            case '7':

                return("Seven Hundred" + and + tenth);

                break;

            case '8':

                return("Eight Hundred" + and + tenth);

                break;

            case '9':

                return("Nine Hundred" + and + tenth);

                break;

            case '0':

                return(tenth);

                break;

            default:
                Console.WriteLine("You entered an invalid input");
                return("Invalid");

                break;
            }
            return("");
        }