Incoming amount required for conversion (string)
public static string Moneytochinese (String stramount) {
string functionreturnvalue = null;
BOOL isnegative = false; Whether it is a negative number
if (Stramount.trim (). Substring (0, 1) = = "-") {
A negative number is a positive number first.
Stramount = Stramount.trim (). Remove (0, 1);
Isnegative = true;
}
string strlower = null;
string strupart = null;
string strupper = null;
int iTemp = 0;
Retains two decimal places 123.489→123.49 123.4→123.4
Stramount = Math.Round (double. Parse (Stramount), 2). ToString ();
if (Stramount.indexof (".") > 0) {
if (Stramount.indexof (".") = = Stramount.length-2) {
Stramount = Stramount + "0";
}
}
else {
Stramount = Stramount + ". 00";
}
Strlower = Stramount;
ITemp = 1;
Strupper = "";
while (iTemp <= strlower.length) {
Switch (strlower.substring (strlower.length-itemp, 1)) {
Case ".":
Strupart = "Circle";
Break
Case "0":
Strupart = "0";
Break
Case "1":
Strupart = "one";
Break
Case "2":
Strupart = "Ii.";
Break
Case "3":
Strupart = "three";
Break
Case "4":
Strupart = "the premises";
Break
Case "5":
Strupart = "WU";
Break
Case "6":
Strupart = "Lu";
Break
Case "7":
Strupart = "Qi";
Break
Case "8":
Strupart = "ba";
Break
Case "9":
Strupart = "JIU";
Break
}
Switch (iTemp) {
Case 1:
Strupart = Strupart + "min";
Break
Case 2:
Strupart = Strupart + "angle";
Break
Case 3:
Strupart = Strupart + "";
Break
Case 4:
Strupart = Strupart + "";
Break
Case 5:
Strupart = Strupart + "pickup";
Break
Case 6:
Strupart = Strupart + "Bai";
Break
Case 7:
Strupart = Strupart + "thousand";
Break
Case 8:
Strupart = Strupart + "million";
Break
Case 9:
Strupart = Strupart + "pickup";
Break
Case 10:
Strupart = Strupart + "Bai";
Break
Case 11:
Strupart = Strupart + "thousand";
Break
Case 12:
Strupart = Strupart + "billion";
Break
Case 13:
Strupart = Strupart + "pickup";
Break
Case 14:
Strupart = Strupart + "Bai";
Break
Case 15:
Strupart = Strupart + "thousand";
Break
Case 16:
Strupart = Strupart + "million";
Break
Default
Strupart = Strupart + "";
Break
}
Strupper = Strupart + strupper;
ITemp = iTemp + 1;
}
Strupper = Strupper.replace ("0 pickup", "0");
Strupper = Strupper.replace ("0 bai", "0");
Strupper = Strupper.replace ("0 thousand", "0");
Strupper = Strupper.replace ("000", "0");
Strupper = Strupper.replace ("00", "0");
Strupper = Strupper.replace ("Certer", "whole");
Strupper = Strupper.replace ("0 points", "whole");
Strupper = Strupper.replace ("0 angle", "0");
Strupper = Strupper.replace ("0 yuan", "million Yuan");
Strupper = Strupper.replace ("Million Zero million round", "Million Round");
Strupper = Strupper.replace ("0", "billion");
Strupper = Strupper.replace ("0 yuan", "Million Round");
Strupper = Strupper.replace ("0", "billion");
Strupper = Strupper.replace ("0", "million");
Strupper = Strupper.replace ("0 Circle", "circle");
Strupper = Strupper.replace ("00", "0");
Treatment of the amount below the circle
if (strupper.substring (0, 1) = = "Circle") {
Strupper = strupper.substring (1, strupper.length-1);
}
if (strupper.substring (0, 1) = = "0") {
Strupper = strupper.substring (1, strupper.length-1);
}
if (strupper.substring (0, 1) = = "Angle") {
Strupper = strupper.substring (1, strupper.length-1);
}
if (strupper.substring (0, 1) = = "Min") {
Strupper = strupper.substring (1, strupper.length-1);
}
if (strupper.substring (0, 1) = = "whole") {
Strupper = "0 round whole";
}
Functionreturnvalue = Strupper;
if (isnegative = = True) {
Return "negative" + functionreturnvalue;
}
else {
return functionreturnvalue;
}
}
C # amount Lowercase converted to uppercase