Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
Dear All
I am working with the finance firm in which i need to display the deal amount in words also .this i am not able to do need Help to resolve this issue for this issue ....
Thanks in advance to all....
Pratham
Posted
Comments
Vani Kulkarni 3-Jul-12 3:00am    
What is the issue you are facing?

hi pratham..
this works fine from 1 to 19999, once go throw it..

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace tryingstartfror4digits
{
class Program
{
    static void Main(string[] args)
    {
        Program pg=new Program();
        Console.WriteLine("Enter ur number");
        int num = Convert.ToInt32(Console.ReadLine());
        if (num <= 19)
        {
            string g = pg.first(num);
            Console.WriteLine("The number is " + g);
        }
        else if ((num >= 20) && (num <= 99))
        {
                if (num % 10 == 0)
                {
                    string g = pg.second(num / 10);
                    Console.WriteLine("The number is " + g);
                }
                else
                {
                    string g = pg.second(num / 10) + pg.first(num % 10);
                    Console.WriteLine("The number is " + g);
                }
          }
        else if((num>=100) && (num<=999))
        {
            int k = num % 100;
            string g = pg.first(num / 100) +pg.third(0) + pg.second(k / 10)+pg.first(k%10);
            Console.WriteLine("The number is " + g);
          }
        else if ((num >= 1000) && (num <= 19999))
        {
            int h=num%1000;
           int k=h%100;
            string g = pg.first(num / 1000) + "Thousand " + pg.first(h/ 100) + pg.third(k) + pg.second(k / 10) + pg.first(k % 10);
            Console.WriteLine("The number is " + g);
        }
        Console.ReadLine();
    }
     public string first(int num)
    {
        string name;
        if (num == 0)
        {
            name = " ";
        }
        else
        {
            string[] arr1 = new string[] { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine" , "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"};
            name = arr1[num - 1];
        }
        return name;
    }
    public string second(int num)
    {
        string name;
        if ((num == 0)||(num==1))
        {
         name = " ";
        }
        else
        {
            string[] arr1 = new string[] { "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };
            name = arr1[num - 2];
        }
        return name;
    }
    public string third(int num)
    {
        string name ;
        if (num == 0)
        {
            name = "";
        }
        else
        {
            string[] arr1 = new string[] { "Hundred" };
            name = arr1[0];
        }
        return name;
    }

}
}

C#



all the best...:)
 
Share this answer
 
Comments
pratham2587 26-Jun-12 8:04am    
i want to display the numerical value from textbox in words ..
Is this code will help for that issue.
sandeep nagabhairava 26-Jun-12 8:08am    
this is the code converting numerical to text format.
pratham2587 26-Jun-12 8:11am    
is this code will help to convert the text box numeric value into words?
 
Share this answer
 
Not able to solve the issue Please help for the same.
Revert with the code for the same .....
 
Share this answer
 
Comments
Vani Kulkarni 3-Jul-12 3:00am    
What is the issue you are facing?
Vani Kulkarni 3-Jul-12 3:01am    
This is not an answer. Please remove it from Solution list.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900