Amount in words in Indian format

Amount in words in Indian format

Hi,

I had coded the following code to convert amount in words. But in the code in the format of US like million. But i need in Lakh and Crore. So pls suggest ideas r post corrected code

string Num2Words(int val)
{
    val_s = input.val.toString();
    th = {"", "thousand", "million", "billion", "trillion"};
    // uncomment this line for English Number System
    // th = {"","thousand","million", "milliard","billion"};
    dg = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
    tn = {"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
    tw = {"twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};
    x = val_s.length();
    if (x  >  15)
    {
        return "too big";
    }
    else
    {
        s = val_s.replaceAll("(?)",",",false).removeFirstOccurence(",").removeLastOccurence(",").toList();
        str = "";
        sk = 1;
        bypass = false;
        for each index i in s
        {
  cur = s.get(i).toLong();
            if (!bypass)
            {
                if (((x  -  i)  %  3)  ==  2)
                {
                    if (cur ==  1)
                    {
  next = s.get(i  +  1).toLong();
                        str = str + tn.get(next) + " ";
                        bypass = true;
                        sk = 1;
                    }
                    else if (cur  !=  0)
                    {
                        str = str + tw.get(cur  -  2) + " ";
                        sk = 1;
                    }
                }
                else if (cur  !=  0)
                {
                    str = str + dg.get(cur) + " ";
                    if (((x  -  i)  %  3)  ==  0)
                    {
                        str = str + "hundred ";
                        sk = 1;
                    }
                }
            }
            else
            {
                bypass = false;
            }
            if (((x  -  i)  %  3)  ==  1)
            {
                if (sk  !=  0)
                {
                    str = (str + th.get(floor(((x  -  i  -  1)  /  3)))) + " ";
                    sk = 0;
                }
            }
        }
        return str;
    }
} 


    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now