// Money class
Using system;
namespace Money {/// /// This class implements Arabic numerals to the Chinese capital conversion /// This class is not illegal to discriminate on the digital method /// /// Please call NumToChn Author: menway /// < / summary> public class money {public money () {// // Todo: add constructor logic here ///} private char X) {string Stringchnames = "zero one two three four five six seven eight nine"; string stringNumNames = "0123456789"; return stringChnNames [stringNumNames.IndexOf (x)];} private string conversion integer million or less (string x) {string [] stringArrayLevelNames = new string [4] { "", "ten", "100 "," Thousand "}; string ret =" "; int i; for (i = x.length-1; i> = 0; I -) IF (x [i] == '0') RET = conversion Digital (x [i]) ret; else ret = conversion number (x [i]) StringArrayLevelNames [X.LENGTH-1-I] ret; while ((i = ret.indexof ("zero zero")) ! = - 1) RET = RET.Remove (I, 1); if (Ret [Ret.Length-1] == 'Zero' && Ret.length> 1) Ret = ret.remove (Ret.length-1, 1); if (ret.length> = 2 && ret.substring (0, 2) == "10") RET = RET.Remove (0, 1); Return Ret;} Private string converted integer (String X) {INT LEN = X.LENGTH; STRING RET, TEMP; IF (LEN <= 4) RET = Transformation Million Integer (X); ELSE IF (LEN <= 8) { RET = converts universal (x.Substring (0, len-4)) "10,000"; TEMP = transformation uniform (x.Substring (LEN-4, 4)); if (Temp.indexof ("Qian ") == - 1 && temp! =" ") RET =" zero " TEMP; ELSE RET = Temp;} else {RET = Transformation universal (x.substring (0, len-8)) " billion "; TEMP = converts universal unity (X.Substring (LEN-8, 4)); if (Temp.indexof (" Thousand ") == - 1 && Temp! =" ") RET =" Zero " TEMP; ELSE RET =
Temp; RET = "10,000"; TEMP = Transformation universal (x.Substring (LEN-4, 4)); if (Temp.indexof ("Thousand") == - 1 && Temp! = "") RET = "Zero" TEMP; Else Ret = Temp;} INT i; if ((i = ret.indexof ("万")))! = - 1) RET = RET.Remove (i 1, 1); while (i = ret.indexof ("zero zero")))! = - 1) RET = RET.Remove (i, 1); if (Ret [Ret.Length-1] == 'zero' && Ret.length> 1 RET = RET.Remove (Ret.Length-1, 1); Return Ret;} Private String RET = ""; for (INT i = 0; i
Public String NumTochn (String X) {if (x.length == 0) Return ""; string rett = ""; if (x [0] == '-') {RET = "negative"; x = x. REMOVE (0, 1);} if (x [0] .tostring () == ".") X = "0" x; if (x [x.length-1] .tostring () == ". ") X = x.remove (x.length-1, 1); if (x.indexof (". ")> - 1) RET = Transformation integer (x.substring (0, x.indexof (". " )) "Point" conversion decimal (x.indexof (".") 1); Else Ret = conversion integer (x); return ret;}}}
// Test Project
Using system;