Q: How do I convert uppercase amounts to lowercase?
A: Simple, very strict format.
Private float Getmoney (string strbig) ...
{
string strexp= "";
string[] Arrbig = new string[] ... {"Whole", "" "," 0 "," +0 "," One "," +1 "," II "," +2 "," three "," +3 "," "Restaurant", "+4", "WU", "+5", "Lu", "+6", "Qi", "+7", "Ba", "+8", "Nine", "+9", "Min", "*0.01", "Horn", "*0.1", "Yuan", "*1", "Pick Up", "*10.00", "Bai", "*100.00", "Qian", "*1000.00", "Million", "*10000.00", "billion", "*100000000.00"};
for (int i = 0; i < strbig.length i++) ...
{for
(int j = 0; J < arrbig.length-1;j+=2)
... {
if (arrbig[j] = = Strbig[i]. ToString ())
... {
Strexp + = arrbig[j + 1]. ToString ();
Continue;
}
}
object Ret=new DataTable (). Compute (Strexp, "");
return float. Parse (ret. ToString ());
Console.WriteLine ("Nine thousand 0 to pick up one Yuan Land Corner"));
Console.WriteLine ("Nine Thousand and a trillion zero to pick one Yuan Getmoney"));
}
The one with the water brother is more ruthless.
public double decodemoneycn (string atext) ...
{atext = Atext.replace ("Absolute", "billion");
Atext = Atext.replace ("point", "Yuan");
Atext = Atext.replace ("block", "Yuan");
Atext = Atext.replace ("Mao", "Horn");
Double vresult = 0; Double vnumber = 0;
Current number Double vtemp = 0; int vdecimal = 0; Whether the decimal point foreach (char vchar in atext) appears ... {int i = ' 0123456789 '.
IndexOf (Vchar); if (i < 0) i = "0 23,456,789".
IndexOf (Vchar); if (i < 0) i = "0 Woolu qi ba Nine".
IndexOf (Vchar); if (i > 0) ...
{vnumber = i; if (Vdecimal > 0) ...
{Vresult + = Vnumber * MATH.POW (-vdecimal);
vdecimal++;
Vnumber = 0; } else ... {i = "meta Chivan".
IndexOf (Vchar); if (i < 0) i = "whole hundred trillion million".
IndexOf (Vchar);
if (i = = 5) i = 8; if (i > 0) ... {if (i >= 4) ...
{vtemp + = Vnumber;
if (vtemp = = 0) vtemp = 1;
Vresult + + vtemp * MATH.POW (i); vtemp = 0;
else Vtemp + = Vnumber * MATH.POW (i); else ... {i = "meta point".
IndexOf (Vchar); if (i > 0) ...
{vtemp + = Vnumber;
Vresult + + vtemp * MATH.POW (a);
vtemp = 0; else if (i = = 0) ...
{vtemp + = Vnumber;
Vresult + = vtemp;
Vdecimal = 1;
vtemp = 0;
} vnumber = 0;
} return Vresult + Vtemp + vnumber; } private void Button2_Click (object sender, EventArgs e) ... {string[] Vtesttext = ...
{"12.56", "100,010,005", "400 million", "9,876,543,210", "5.1 yuan Four points", "one Bai Yuan whole", "35 million", "9.2 Yuan"}; foreach (String vtext in Vtesttext) ...
{Console.WriteLine ("Decodemoneycn (" {0} ") ={1}", Vtext, DECODEMONEYCN (Vtext)); }
}