dkchinnari Posted July 25, 2011 Report Posted July 25, 2011 [quote author=Maddy_Rulez link=topic=127624.msg2660200#msg2660200 date=1311611011] thankyou thankyou thankyou thankyou[/quote]nu endku google cheyalee sCo_^Ynaku idi maa frnd cheppadu..he is working on .net...google chesadu
Jambhalheart Posted July 25, 2011 Report Posted July 25, 2011 ok here is my code for this one[img]http://i.picasion.com/pic43/81ef3c006778eaab6116e05d4fe1330b.gif[/img](.cs code)using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;public partial class Number_to_Text : System.Web.UI.Page{ string strNumber = string.Empty; string strResult = string.Empty; int intNumber = 0; int intReverse = 0; int intRemainder = 0; int intQuot = 10; protected void Page_Load(object sender, EventArgs e) { } protected void btn_Click(object sender, EventArgs e) { strNumber = txt.Text; intNumber = Convert.ToInt32(strNumber); int j = 0; for (double i = 0; i < 3; i++) { if (i == 0) j = 100; else if (i == 1) j = 10; else if (i == 2) j = 1; intRemainder = (intNumber % 10) * j; intNumber = intNumber / 10; intReverse += intRemainder; } ViewState["Reverse"] = intReverse; lblResult.Text = ToWords(intReverse); // SecondDigit(); // ThirdDigit(); } private int ThirdDigit() { intNumber = Convert.ToInt32(ViewState["Reverse"].ToString()); for (int i = 0; i < 3; i++) { intRemainder = (intNumber % 10); intNumber = intNumber / 10; } return intRemainder; } private int SecondDigit() { strNumber = txt.Text; intNumber = Convert.ToInt32(strNumber); for (int i = 0; i < 2; i++) { intRemainder = (intNumber % 10); intNumber = intNumber / 10; } return intRemainder; } private string Third() { switch (ThirdDigit()) { case 0: strResult += "Ten"; break; case 1: strResult += "Eleven"; break; case 2: strResult += "Twelve"; break; case 3: strResult += "Thirdteen"; break; case 4: strResult += "Fourteen"; break; case 5: strResult += "Fifteen"; break; case 6: strResult += "Sixteen"; break; case 7: strResult += "Seventeen"; break; case 8: strResult += "Eighteen"; break; case 9: strResult += "Ninteen"; break; } return strResult; } private string ToWords(int x) { // int intTemp; int intRem; int intq; intRem = x; for (int i = 0; i < 3; i++) { intq = intRem % 10; intRem = intRem / 10; switch (intq) { case 1: if (i == 0) { strResult += "One Hundred and "; if(SecondDigit()==0 && ThirdDigit()==0) strResult = "One Hundred"; } else if (i == 1) { if (SecondDigit() == 0) strResult += string.Empty; if (SecondDigit() == 1) { return Third(); } //if (SecondDigit() != 0 && SecondDigit() != 1) //{ // strResult += "Ten"; //} } else if (i == 2) strResult += "One"; break; case 2: if (i == 0) strResult += "Two Hundred and "; if (SecondDigit() == 0 && ThirdDigit() == 0) strResult = "Two Hundred"; else if (i == 1) { if (SecondDigit() == 0) strResult += string.Empty; if (SecondDigit() == 1) { //Third(); return Third(); } if (SecondDigit() != 0 && SecondDigit() != 1) { strResult += "Twenty "; } } else if (i == 2) strResult += "Two"; break; case 3: if (i == 0) strResult += "Three Hundred and "; if (SecondDigit() == 0 && ThirdDigit() == 0) strResult = "Three Hundred"; else if (i == 1) { if (SecondDigit() == 0) strResult += string.Empty; if (SecondDigit() == 1) { // Third(); return Third(); } if (SecondDigit() != 0 && SecondDigit() != 1) { strResult += "Thirty "; } } else if (i == 2) strResult += "Three"; break; case 4: if (i == 0) strResult += "Four Hundred and "; if (SecondDigit() == 0 && ThirdDigit() == 0) strResult = "Four Hundred"; else if (i == 1) { if (SecondDigit() == 0) strResult += string.Empty; if (SecondDigit() == 1) { //Third(); return Third(); } if (SecondDigit() != 0 && SecondDigit() != 1) { strResult += "Forty "; } } else if (i == 2) strResult += "Four"; break; case 5: if (i == 0) strResult += "Five Hundred and "; if (SecondDigit() == 0 && ThirdDigit() == 0) strResult = "Five Hundred"; else if (i == 1) { if (SecondDigit() == 0) strResult += string.Empty; if (SecondDigit() == 1) { //Third(); return Third(); } if (SecondDigit() != 0 && SecondDigit() != 1) { strResult += "Fifty "; } } else if (i == 2) strResult += "Five"; break; case 6: if (i == 0) strResult += "Six Hundred and "; if (SecondDigit() == 0 && ThirdDigit() == 0) strResult = "Six Hundred"; else if (i == 1) { if (SecondDigit() == 0) strResult += string.Empty; if (SecondDigit() == 1) { // Third(); return Third(); } if (SecondDigit() != 0 && SecondDigit() != 1) { strResult += "Sixty "; } } else if (i == 2) strResult += "Six"; break; case 7: if (i == 0) strResult += "Seven Hundred and "; if (SecondDigit() == 0 && ThirdDigit() == 0) strResult = "Seven Hundred"; else if (i == 1) { if (SecondDigit() == 0) strResult += string.Empty; if (SecondDigit() == 1) { // Third(); return Third(); } if (SecondDigit() != 0 && SecondDigit() != 1) { strResult += "Seventy "; } } else if (i == 2) strResult += "Seven"; break; case 8: if (i == 0) strResult += "Eight Hundred and "; if (SecondDigit() == 0 && ThirdDigit() == 0) strResult = "Eight Hundred"; else if (i == 1) { if (SecondDigit() == 0) strResult += string.Empty; if (SecondDigit() == 1) { // Third(); return Third(); } if (SecondDigit() != 0 && SecondDigit() != 1) { strResult += "Eighty "; } } else if (i == 2) strResult += "Eight"; break; case 9: if (i == 0) strResult += "Nine Hundred and "; if (SecondDigit() == 0 && ThirdDigit() == 0) strResult = "Nine Hundred"; else if (i == 1) { if (SecondDigit() == 0) strResult += string.Empty; if (SecondDigit() == 1) { // Third(); return Third(); } if (SecondDigit() != 0 && SecondDigit() != 1) { strResult += "Ninety "; } } else if (i == 2) strResult += "Nine"; break; } } return strResult; }}and now for this one...[img width=450 height=237]http://i.picasion.com/pic43/d12698fb24b9d9bf445801551da2e9ca.gif[/img]using System;using System.Collections;using System.Configuration;using System.Data;using System.Linq;using System.Text;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;public partial class Word_count : System.Web.UI.Page{ StringBuilder sb = new StringBuilder(); string[] strWords; int intCount = 0; protected void Page_Load(object sender, EventArgs e) { } private string Returnstring(int x) { string str = string.Empty; switch (x) { case 0: str = "Zero"; break; case 1: str = "One"; break; case 3: str = "Three"; break; case 4: str = "Four"; break; case 5: str = "Five"; break; case 6: str = "Six"; break; case 7: str = "Seven"; break; case 8: str = "Eight"; break; case 9: str = "Nine"; break; } return str; } protected void btn_Click(object sender, EventArgs e) { strWords = txt.Text.Split(' '); int[] arrCount = new int[txt.Text.Length]; foreach (int i in arrCount) { arrCount[i] = 0; } string strResult = string.Empty; foreach (string str in strWords) { arrCount.SetValue(Convert.ToInt32(arrCount[str.Length].ToString())+1,str.Length); //sb.Insert(0, "No. of " + Returnstring(str.Length) + " words are : " + arrCount[str.Length].ToString());// // intCount=0; } arrCount[0] = 0; for (int i = 0; i < arrCount.Length;i++) { if (Convert.ToInt32(arrCount[i].ToString()) > 0) strResult = strResult + "No. of " + Returnstring(i) + " letter words " + arrCount[i].ToString() + "<br />"; } lbl.Text = strResult; }}
Jambhalheart Posted July 25, 2011 Report Posted July 25, 2011 ok pends,, please suggest any improvement in my code... any suggestion small to big will be thanked with full heart....
Jambhalheart Posted July 25, 2011 Report Posted July 25, 2011 [quote author=vishwamithra link=topic=127624.msg2660205#msg2660205 date=1311611070]nu endku google cheyalee sCo_^Ynaku idi maa frnd cheppadu..he is working on .net...google chesadu[/quote]maa appice lo google ban anna... thats problem.. vadu morning cheppadu naku, nenu alochinchi cheptha annanu... sCo_^Y
dkchinnari Posted July 25, 2011 Report Posted July 25, 2011 [quote author=Maddy_Rulez link=topic=127624.msg2660230#msg2660230 date=1311611369]maa appice lo google ban anna... thats problem.. vadu morning cheppadu naku, nenu alochinchi cheptha annanu... sCo_^Y[/quote]ok.. g0ssIp H&*() S%Hi
lolliman Posted July 25, 2011 Report Posted July 25, 2011 [quote author=Maddy_Rulez link=topic=127624.msg2660224#msg2660224 date=1311611259]ok pends,, please suggest any improvement in my code... any suggestion small to big will be thanked with full heart....[/quote]baa idi only three digits kena sCo_^Y sCo_^Y sCo_^Y sCo_^Y sCo_^Y
Jambhalheart Posted July 25, 2011 Report Posted July 25, 2011 [quote author=lolliman link=topic=127624.msg2660543#msg2660543 date=1311614873]baa idi only three digits kena sCo_^Y sCo_^Y sCo_^Y sCo_^Y sCo_^Y[/quote]avunu baa.. only 3 digits ke cheddam anukoni chesa... S%Hi edhi naa 1st year JNTU lo paper leak ayina tharvatha sets introduce chesi nappudu C language lo question edhi... C language lo ee program rayadam ante... @3$% @3$%
lolliman Posted July 25, 2011 Report Posted July 25, 2011 [quote author=Maddy_Rulez link=topic=127624.msg2660587#msg2660587 date=1311615224]avunu baa.. only 3 digits ke cheddam anukoni chesa... S%Hi edhi naa 1st year JNTU lo paper leak ayina tharvatha sets introduce chesi nappudu C language lo question edhi... C language lo ee program rayadam ante... @3$% @3$%[/quote]idi choodu baa code VB lo vundiModule Module1 Function strReplicate(ByVal str As String, ByVal intD As Integer) As String 'This fucntion padded "0" after the number to evaluate hundred, thousand and on.... 'using this function you can replicate any Charactor with given string. Dim i As Integer strReplicate = "" For i = 1 To intD strReplicate = strReplicate + str Next Return strReplicate End Function Function AmtInWord(ByVal Num As Decimal) As String 'I have created this function for converting amount in indian rupees (INR). 'You can manipulate as you wish like decimal setting, Doller (any currency) Prefix. Dim strNum As String Dim strNumDec As String Dim StrWord As String strNum = Num If InStr(1, strNum, ".") <> 0 Then strNumDec = Mid(strNum, InStr(1, strNum, ".") + 1) If Len(strNumDec) = 1 Then strNumDec = strNumDec + "0" End If If Len(strNumDec) > 2 Then strNumDec = Mid(strNumDec, 1, 2) End If strNum = Mid(strNum, 1, InStr(1, strNum, ".") - 1) StrWord = IIf(CDbl(strNum) = 1, " Rupee ", " Rupees ") + NumToWord(CDbl(strNum)) + IIf(CDbl(strNumDec) > 0, " and Paise" + cWord3(CDbl(strNumDec)), "") Else StrWord = IIf(CDbl(strNum) = 1, " Rupee ", " Rupees ") + NumToWord(CDbl(strNum)) End If AmtInWord = StrWord & " Only" Return AmtInWord End Function Function NumToWord(ByVal Num As Decimal) As String 'I divided this function in two part. '1. Three or less digit number. '2. more than three digit number. Dim strNum As String Dim StrWord As String strNum = Num If Len(strNum) <= 3 Then StrWord = cWord3(CDbl(strNum)) Else StrWord = cWordG3(CDbl(Mid(strNum, 1, Len(strNum) - 3))) + " " + cWord3(CDbl(Mid(strNum, Len(strNum) - 2))) End If NumToWord = StrWord End Function Function cWordG3(ByVal Num As Decimal) As String '2. more than three digit number. Dim strNum As String = "" Dim StrWord As String = "" Dim readNum As String = "" strNum = Num If Len(strNum) Mod 2 <> 0 Then readNum = CDbl(Mid(strNum, 1, 1)) If readNum <> "0" Then StrWord = retWord(readNum) readNum = CDbl("1" + strReplicate("0", Len(strNum) - 1) + "000") StrWord = StrWord + " " + retWord(readNum) End If strNum = Mid(strNum, 2) End If While Not Len(strNum) = 0 readNum = CDbl(Mid(strNum, 1, 2)) If readNum <> "0" Then StrWord = StrWord + " " + cWord3(readNum) readNum = CDbl("1" + strReplicate("0", Len(strNum) - 2) + "000") StrWord = StrWord + " " + retWord(readNum) End If strNum = Mid(strNum, 3) End While cWordG3 = StrWord Return cWordG3 End Function Function cWord3(ByVal Num As Decimal) As String '1. Three or less digit number. Dim strNum As String = "" Dim StrWord As String = "" Dim readNum As String = "" If Num < 0 Then Num = Num * -1 strNum = Num If Len(strNum) = 3 Then readNum = CDbl(Mid(strNum, 1, 1)) StrWord = retWord(readNum) + " Hundred" strNum = Mid(strNum, 2, Len(strNum)) End If If Len(strNum) <= 2 Then If CDbl(strNum) >= 0 And CDbl(strNum) <= 20 Then StrWord = StrWord + " " + retWord(CDbl(strNum)) Else StrWord = StrWord + " " + retWord(CDbl(Mid(strNum, 1, 1) + "0")) + " " + retWord(CDbl(Mid(strNum, 2, 1))) End If End If strNum = CStr(Num) cWord3 = StrWord Return cWord3 End Function Function retWord(ByVal Num As Decimal) As String 'This two dimensional array store the primary word convertion of number. retWord = "" Dim ArrWordList(,) As Object = {{0, ""}, {1, "One"}, {2, "Two"}, {3, "Three"}, {4, "Four"}, _ {5, "Five"}, {6, "Six"}, {7, "Seven"}, {8, "Eight"}, {9, "Nine"}, _ {10, "Ten"}, {11, "Eleven"}, {12, "Twelve"}, {13, "Thirteen"}, {14, "Fourteen"}, _ {15, "Fifteen"}, {16, "Sixteen"}, {17, "Seventeen"}, {18, "Eighteen"}, {19, "Nineteen"}, _ {20, "Twenty"}, {30, "Thirty"}, {40, "Forty"}, {50, "Fifty"}, {60, "Sixty"}, _ {70, "Seventy"}, {80, "Eighty"}, {90, "Ninety"}, {100, "Hundred"}, {1000, "Thousand"}, _ {100000, "Lakh"}, {10000000, "Crore"}} Dim i As Integer For i = 0 To UBound(ArrWordList) If Num = ArrWordList(i, 0) Then retWord = ArrWordList(i, 1) Exit For End If Next Return retWord End FunctionEnd Module
lolliman Posted July 25, 2011 Report Posted July 25, 2011 [quote author=lolliman link=topic=127624.msg2660606#msg2660606 date=1311615490]idi choodu baa code VB lo vundiModule Module1 [color=red] Function strReplicate(ByVal str As String, ByVal intD As Integer) As String 'This fucntion padded "0" after the number to evaluate hundred, thousand and on.... 'using this function you can replicate any Charactor with given string. Dim i As Integer strReplicate = "" For i = 1 To intD strReplicate = strReplicate + str Next Return strReplicate End Function[/color] [color=green]Function AmtInWord(ByVal Num As Decimal) As String 'I have created this function for converting amount in indian rupees (INR). 'You can manipulate as you wish like decimal setting, Doller (any currency) Prefix. Dim strNum As String Dim strNumDec As String Dim StrWord As String strNum = Num If InStr(1, strNum, ".") <> 0 Then strNumDec = Mid(strNum, InStr(1, strNum, ".") + 1) If Len(strNumDec) = 1 Then strNumDec = strNumDec + "0" End If If Len(strNumDec) > 2 Then strNumDec = Mid(strNumDec, 1, 2) End If strNum = Mid(strNum, 1, InStr(1, strNum, ".") - 1) StrWord = IIf(CDbl(strNum) = 1, " Rupee ", " Rupees ") + NumToWord(CDbl(strNum)) + IIf(CDbl(strNumDec) > 0, " and Paise" + cWord3(CDbl(strNumDec)), "") Else StrWord = IIf(CDbl(strNum) = 1, " Rupee ", " Rupees ") + NumToWord(CDbl(strNum)) End If AmtInWord = StrWord & " Only" Return AmtInWord End Function[/color] [color=red]Function NumToWord(ByVal Num As Decimal) As String 'I divided this function in two part. '1. Three or less digit number. '2. more than three digit number. Dim strNum As String Dim StrWord As String strNum = Num If Len(strNum) <= 3 Then StrWord = cWord3(CDbl(strNum)) Else StrWord = cWordG3(CDbl(Mid(strNum, 1, Len(strNum) - 3))) + " " + cWord3(CDbl(Mid(strNum, Len(strNum) - 2))) End If NumToWord = StrWord End Function[/color] [color=green] Function cWordG3(ByVal Num As Decimal) As String '2. more than three digit number. Dim strNum As String = "" Dim StrWord As String = "" Dim readNum As String = "" strNum = Num If Len(strNum) Mod 2 <> 0 Then readNum = CDbl(Mid(strNum, 1, 1)) If readNum <> "0" Then StrWord = retWord(readNum) readNum = CDbl("1" + strReplicate("0", Len(strNum) - 1) + "000") StrWord = StrWord + " " + retWord(readNum) End If strNum = Mid(strNum, 2) End If While Not Len(strNum) = 0 readNum = CDbl(Mid(strNum, 1, 2)) If readNum <> "0" Then StrWord = StrWord + " " + cWord3(readNum) readNum = CDbl("1" + strReplicate("0", Len(strNum) - 2) + "000") StrWord = StrWord + " " + retWord(readNum) End If strNum = Mid(strNum, 3) End While cWordG3 = StrWord Return cWordG3 End Function[/color] [color=orange] Function cWord3(ByVal Num As Decimal) As String '1. Three or less digit number. Dim strNum As String = "" Dim StrWord As String = "" Dim readNum As String = "" If Num < 0 Then Num = Num * -1 strNum = Num If Len(strNum) = 3 Then readNum = CDbl(Mid(strNum, 1, 1)) StrWord = retWord(readNum) + " Hundred" strNum = Mid(strNum, 2, Len(strNum)) End If If Len(strNum) <= 2 Then If CDbl(strNum) >= 0 And CDbl(strNum) <= 20 Then StrWord = StrWord + " " + retWord(CDbl(strNum)) Else StrWord = StrWord + " " + retWord(CDbl(Mid(strNum, 1, 1) + "0")) + " " + retWord(CDbl(Mid(strNum, 2, 1))) End If End If strNum = CStr(Num) cWord3 = StrWord Return cWord3 End Function[/color] Function retWord(ByVal Num As Decimal) As String 'This two dimensional array store the primary word convertion of number. retWord = "" Dim ArrWordList(,) As Object = {{0, ""}, {1, "One"}, {2, "Two"}, {3, "Three"}, {4, "Four"}, _ {5, "Five"}, {6, "Six"}, {7, "Seven"}, {8, "Eight"}, {9, "Nine"}, _ {10, "Ten"}, {11, "Eleven"}, {12, "Twelve"}, {13, "Thirteen"}, {14, "Fourteen"}, _ {15, "Fifteen"}, {16, "Sixteen"}, {17, "Seventeen"}, {18, "Eighteen"}, {19, "Nineteen"}, _ {20, "Twenty"}, {30, "Thirty"}, {40, "Forty"}, {50, "Fifty"}, {60, "Sixty"}, _ {70, "Seventy"}, {80, "Eighty"}, {90, "Ninety"}, {100, "Hundred"}, {1000, "Thousand"}, _ {100000, "Lakh"}, {10000000, "Crore"}} Dim i As Integer For i = 0 To UBound(ArrWordList) If Num = ArrWordList(i, 0) Then retWord = ArrWordList(i, 1) Exit For End If Next Return retWord End FunctionEnd Module[/quote]
Jambhalheart Posted July 25, 2011 Report Posted July 25, 2011 [quote author=lolliman link=topic=127624.msg2660615#msg2660615 date=1311615607]piana code upto 8 digits varaku vundi[/quote]Vb naku radhu baa... kani nee logic koncham bagundi... basic theme is to keep them something like switch case when 1 comes "one" is selected annattu... and nenu alochinchinadhi enti ante, eppudu 701 ani vunnadu 0 vaste string.empty pettadam, alage, 600 ani vasthe 2 string.emptys vasthayi.. and second digit 1 vasthe, appudu digit find chesi appudu find cheyadam, like 11 is eleven, 12 is twelve and so on... but ur code is good one. S%Hi good on u mate H&*()
Pekatapaparao Posted July 25, 2011 Report Posted July 25, 2011 @3$% @3$% @3$%mee company codelu anni ikkada vestunaru baaaaaaaaaaa evaru ee company ooo copy rights kuda veyandi @3$% @3$%
Jambhalheart Posted July 25, 2011 Report Posted July 25, 2011 [quote author=★-- ♕ PEKATAPAPARAO ♕ --★ link=topic=127624.msg2660719#msg2660719 date=1311616883] @3$% @3$% @3$%mee company codelu anni ikkada vestunaru baaaaaaaaaaa evaru ee company ooo copy rights kuda veyandi @3$% @3$%[/quote]nadhi aithe naa own code.... weekend mandhi vesi mari chesanu... promise, nee medha ottu
Jambhalheart Posted July 25, 2011 Report Posted July 25, 2011 nuvvu kuda neeku nachina language lo try sesi veyochu kadha... nee talent tho memu, maa talent tho nuvvu, parichayalu penchukundam J@#D J@#D J@#D
Pekatapaparao Posted July 25, 2011 Report Posted July 25, 2011 [quote author=Maddy_Rulez link=topic=127624.msg2660724#msg2660724 date=1311616962]nadhi aithe naa own code.... weekend mandhi vesi mari chesanu... promise, nee medha ottu[/quote]mandesaka code rasava ? nuvvu kirak mama[img]http://lh3.ggpht.com/_KVkPY2XIbRQ/TWAgXprYLuI/AAAAAAAABCo/VzL0ae41lc4/brahmi%20laugh.gif[/img]
Recommended Posts