1,105,254 Community Members

Convert words into numbers

Member Avatar
avirag
Posting Whiz
312 posts since Jun 2009
Reputation Points: 10 [?]
Q&As Helped to Solve: 36 [?]
Skill Endorsements: 0 [?]
 
-1
 

Hi! how can I convert words into numerals...
for Example we enter "One crore twenty lakh thirty four thousand seven hundred eighty four" ,
then its corresponding numeral should be "12034784".

What will be the C# code for finding corresponding numerals for range 0 to 999999999 .....

Member Avatar
DdoubleD
Posting Shark
984 posts since Jul 2009
Reputation Points: 315 [?]
Q&As Helped to Solve: 235 [?]
Skill Endorsements: 5 [?]
 
0
 

Here is an interesting article that allows you to code your own using mixed-language: http://www.blackwasp.co.uk/NumberToWords.aspx

Member Avatar
__avd
Posting Genius (adatapost)
6,703 posts since Oct 2008
Reputation Points: 1,811 [?]
Q&As Helped to Solve: 1,272 [?]
Skill Endorsements: 61 [?]
Moderator
 
0
 

Use Hashtable class where you may assign value at unique key.

Hashtable hs = new Hashtable();
        hs.Add("thousand", 1000);
        hs.Add("hundred", 100);
        hs.Add("one", 1);
        hs.Add("two", 2);
        string[] ar = "one thousand two hundred".Split(' ');
        int no = 0;
        for (int i = 0; i < ar.Length; i+=2)
        {
            no= no + (int) hs[ar[i]]  * (int) hs[ar[i+1]]; 

        }
        Console.WriteLine(no)
Member Avatar
vinnijain
Junior Poster
145 posts since Jul 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 12 [?]
Skill Endorsements: 3 [?]
 
-1
 

Hi adatapost,
u have given me code only for specific value .....
Kindly give me general code in C#

Member Avatar
vinnijain
Junior Poster
145 posts since Jul 2009
Reputation Points: 0 [?]
Q&As Helped to Solve: 12 [?]
Skill Endorsements: 3 [?]
 
1
 

Hi ,DdoubleD!!!
I have already done coding for number to words conversion......
Kindly tell me for words to number conversion

Member Avatar
DdoubleD
Posting Shark
984 posts since Jul 2009
Reputation Points: 315 [?]
Q&As Helped to Solve: 235 [?]
Skill Endorsements: 5 [?]
 
0
 

That is a little more tricky, but not too much. Here is a code snippet written in Python that should give you the general idea. If you don't know Python (I don't), the syntax is similar enough I think you will understand it: http://stackoverflow.com/questions/493174/is-there-a-way-to-convert-number-words-to-integers-python

Question Answered as of 4 Years Ago by DdoubleD, vinnijain and __avd
Member Avatar
soulcandra44
Newbie Poster
14 posts since Aug 2010
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
-2
 

make program that words convert to numbers. using #include<stdio.h> and using switch. (1-50) i need it badly pls post here!

Member Avatar
Ryshad
Nearly a Posting Virtuoso
1,263 posts since Aug 2009
Reputation Points: 480 [?]
Q&As Helped to Solve: 247 [?]
Skill Endorsements: 14 [?]
 
0
 

please do not resurrect old threads to post new questions.
Also, we have a strict policy here at daniweb to help thosde who show effort. Since
this thread was solved, read through the code given and try to modify it to meet your own requirements, then post your own question with your code so far if you need specific help

Member Avatar
soulcandra44
Newbie Poster
14 posts since Aug 2010
Reputation Points: -2 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

plsss.. bec. im new with this. only this program pls!

Member Avatar
Ryshad
Nearly a Posting Virtuoso
1,263 posts since Aug 2009
Reputation Points: 480 [?]
Q&As Helped to Solve: 247 [?]
Skill Endorsements: 14 [?]
 
1
 

There are lots of solvers here who will be happy to help you, provided you keep within the rules. So, stop posting in this old thread and start a new thread with your own question. Be more specific, give details of what you are trying to achieve. Most importantly, try for yourself first. We are not going to hand you a complete code solution. There is a link in the post above to some python code which you can use as a basis for your work. Make an attempt at solving the problem then post if you have a specific issue, including the code you have so far.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article