Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 26-Jun-12 1:39am
Comments
Vani Kulkarni at 3-Jul-12 3:00am
   
What is the issue you are facing?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hi pratham..
this works fine from 1 to 19999, once go throw it..
 
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;
    }
 
}
}

 
all the best...Smile | :)
  Permalink  
Comments
pratham2587 at 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 at 26-Jun-12 8:08am
   
this is the code converting numerical to text format.
pratham2587 at 26-Jun-12 8:11am
   
is this code will help to convert the text box numeric value into words?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Not able to solve the issue Please help for the same.
Revert with the code for the same .....
  Permalink  
Comments
Vani Kulkarni at 3-Jul-12 3:00am
   
What is the issue you are facing?
Vani Kulkarni at 3-Jul-12 3:01am
   
This is not an answer. Please remove it from Solution list.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
Please Check the link below.
 
http://stackoverflow.com/questions/2729752/converting-numbers-in-to-words-c-sharp[^]
 
Regards,
Raghu
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 310
1 Sergey Alexandrovich Kryukov 202
2 Richard MacCutchan 160
3 PhilLenoir 154
4 Sharmanuj 146
0 Sergey Alexandrovich Kryukov 5,999
1 OriginalGriff 5,115
2 CPallini 2,473
3 Richard MacCutchan 1,597
4 Abhinav S 1,505


Advertise | Privacy | Mobile
Web01 | 2.8.140814.1 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100