How can I find numeral for given expanded form......In the window application , user enters expanded form in first textbox......Now on button click user should get equivalent number in second textbox.
For example:user enters "thirty nine crore twenty lakh thirty five thousand seven hundred eighty three"
Its numeral should be:"392035783"
How can i do this in window application form (C#).
Loading

Sanjay Chauhan55 reputationPosted Aug 13, 2009, 4:31 AM EDT
Take the reference of these articles.
http://www.c-sharpcorner.com/UploadFile/mgold/CodeDomCalculator08082005003253AM/CodeDomCalculator.aspx
and
http://riteshk.blogspot.com/2007/05/how-to-calculate-value-with-regular.html
Master BillaRank #2,229 · 630 reputationPosted Aug 10, 2009, 7:22 PM EDT
This is you are expecting.
http://www.codeproject.com/KB/cs/codesamples.aspx
Thank you
vinni jain109 reputationPosted Aug 10, 2009, 8:15 PM EDT
The given expanded form is: 2*10000000 + 5*100000 + 7*1000 + 9*100 + 5*1
Its answer will be : 20507905.
I want code for this..........
How to generate number for each expanded form like above
Sanjay Chauhan55 reputationPosted Aug 11, 2009, 3:06 AM EDT
Here is the answer
protected void Button1_Click(object sender, EventArgs e)
{
Hashtable hashTable = new Hashtable();
hashTable.Add("one", "1");
hashTable.Add("two", "2");
hashTable.Add("three", "3");
hashTable.Add("four", "4");
hashTable.Add("five", "5");
hashTable.Add("six", "6");
hashTable.Add("seven", "7");
hashTable.Add("eight", "8");
hashTable.Add("nine", "9");
hashTable.Add("ten", "10");
hashTable.Add("eleven", "11");
hashTable.Add("twelve", "12");
hashTable.Add("thirteen", "13");
hashTable.Add("fourteen", "14");
hashTable.Add("fifteen", "15");
hashTable.Add("sixteen", "16");
hashTable.Add("seventeen", "17");
hashTable.Add("eighteen", "18");
hashTable.Add("nineteen", "19");
hashTable.Add("twenty", "20");
hashTable.Add("thirty", "30");
hashTable.Add("fourty", "40");
hashTable.Add("fifty", "50");
hashTable.Add("sixty", "60");
hashTable.Add("seventy", "70");
hashTable.Add("eighty", "80");
hashTable.Add("ninety", "90");
hashTable.Add("hundred", "100");
hashTable.Add("thousand", "1000");
hashTable.Add("lakh", "100000");
hashTable.Add("crore", "10000000");
string wordValue = TextBox1.Text.Trim().ToLower();
string[] strArray = wordValue.Split(' ');
int value = 0;
int tempValue = 0;
foreach (string s in strArray)
{
if (object.Equals(s, "hundred") || object.Equals(s, "thousand") || object.Equals(s, "lakh") || object.Equals(s, "crore"))
{
value += tempValue * int.Parse(hashTable[s].ToString());
tempValue = 0;
}
else
{
if (hashTable.ContainsKey(s))
{
tempValue += int.Parse(hashTable[s].ToString());
}
}
}
TextBox1.Text = (value + tempValue).ToString();
}
Happy Coding!
vinni jain109 reputationPosted Aug 11, 2009, 11:04 AM EDT
The given expanded form is: 2*10000000 + 5*100000 + 7*1000 + 9*100 + 5*1
Its answer will be : 20507905.
I want code for this..........
How to generate number for each expanded form like above
Sanjay Chauhan55 reputationPosted Aug 12, 2009, 7:19 PM EDT
Please clarify your problem in more detail.
Thanks
vinni jain109 reputationPosted Aug 12, 2009, 8:15 PM EDT
If suppose user enters " 2*1000000 + 5*10000 + 9*1000 + 7*100 + 4*10 + 3*1 " in first textbox.
Then on button click answer should be " 2059743 "........
Now my problem is that how will the code parse the string and give the equivalent answer.
vinni jain109 reputationPosted Aug 13, 2009, 10:06 PM EDT
These links are very helpful......Now I can do my coding .
I want to ask one thing....
U gave me the code for Words to number conversion.In that code ,I added for million and billion also.But the problem is that its giving wrong answer for:"One million two hundred eighty six thousand four hundred seventy five"...
How can i modify my code for such input...
vinni jain109 reputationPosted Aug 14, 2009, 5:28 AM EDT
I tried these links and build a code......
But the problem is that my code is parsing the string in sequence i.e its giving different answer from what we get by using BODMAS rule.........
Kindly give me some solution......