1

I have created a program to convert amount in words. Its working fine up to 99999 amount values. Can't convert the other numbers and its not allowing cents. Can anyone help me to solve this issue? Below is my code:

    private void button1_Click(object sender, EventArgs e)
    {
        string[] Ones = { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen" };
        string[] Tens = { "Ten", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };
        string[] oo = { "Hundred", "Two Hundred", "Three Hundred", "Four Hundred", "Five Hundred", "Six Hundred", "Seven Hundred", "Eight Hundred", "Nine Hundred" };
        string[] Hundreds = { "one hundred thousand ", "two hundred thousand ", "three hundred ", "Four hundred", "Five hundred", "Six hundred", "Seven hundred", "Eight hundred", "Nine Hundred" };


        int no = int.Parse(textBox3.Text);
        string strWords = "";
        if (no > 99999 && no < 1000000)
        {
            int i = no / 100000;
            strWords = strWords + oo[i - 1] + "";
            no = no % 100000;
        }

        if (no > 99999 && no < 1000000)
        {
            int i = no / 100000;
            strWords = strWords + Hundreds[i - 1] + "";
            no = no % 100000;
        }

        if (no > 9999 && no < 100000)
        {
            int i = no / 10000;
            strWords = strWords + Tens[i - 1] + " ";
            no = no % 10000;
        }

        if (no > 999 && no < 10000)
        {
            int i = no / 1000;
            strWords = strWords + Ones[i - 1] + " Thousand ";
            no = no % 1000;
        }


        if (no > 99 && no < 1000)
        {
            int i = no / 100;
            strWords = strWords + Ones[i - 1] + " Hundred ";
            no = no % 100;
        }

        if (no > 19 && no < 100)
        {
            int i = no / 10;
            strWords = strWords + Tens[i - 1] + " ";
            no = no % 10;
        }

        if (no > 0 && no < 20)
        {
            strWords = strWords + Ones[no - 1];
        }

        textBox4.Text = strWords + " only"; 
    }
samgak
  • 23,944
  • 4
  • 60
  • 82
Mohamed Shakir
  • 65
  • 1
  • 11
  • try this http://www.dotnetpickles.com/2013/03/code-convert-rupeesnumbers-into-words.html and http://www.aspdotnet-suresh.com/2014/08/aspnet-convert-numbers-to-words-string-in-csharp.html – Frebin Francis Feb 27 '15 at 06:39

0 Answers0