Convert the numeric amount into a Chinese amount. For example: 23424.12 ----> erwanqianyi si Yuan points. Depressed... turn over (lessons ).
Import java. Math. bigdecimal;
Public class chinesecurrency {
// Array of Chinese AMOUNT UNITS
String [] arrchineseunit = {"Minute", "angle", "circle", "Pick", "Hour", "Ten Thousand", "Pick ", "Province ",
"Proportion", "million", "Pick", "weight", "weight "};
// Chinese numeric character array
String [] arrchinesenum = {"zero", "one", "two", "three", "Si", "Wu", "Lu", "Lu ", "identifier", "identifier "};
/**
* Description converts the numeric amount to the Chinese amount
*
* @ Param bigdecimal
* Number before bigdmoneynumber Conversion
* @ Return string call: <br/>
* Mytochinesecurrency ("101.89") = ""
* Mytochinesecurrency ("100.89") = ""
* Mytochinesecurrency ("100") = ""
*/
Public String donumbercurrencytochinesecurrency (bigdecimal moneynumber ){
String strchinesecurrency = "";
// Zero-digit mark
Boolean iszero = true;
// Chinese amount unit subscript
Int chineseunitindex = 0;
Try {
If (moneynumber. intvalue () = 0 ){
Return "Zero circle ";
}
// Process the decimal part, rounded down
Double doubmoneynumber = math
. Round (moneynumber. doublevalue () * 100 );
// Whether it is negative
Boolean bnegative = doubmoneynumber <0;
// Obtain the absolute value
Doubmoneynumber = math. Abs (doubmoneynumber );
// Process the conversion operation cyclically
While (doubmoneynumber> 0 ){
// Processing (no decimal places)
If (chineseunitindex = 2 & strchinesecurrency. Length () = 0)
Strchinesecurrency = strchinesecurrency + "whole ";
// Processing of non-zero digits
If (doubmoneynumber % 10> 0 ){
Strchinesecurrency = arrchinesenum [(INT) doubmoneynumber % 10]
+ Arrchineseunit [chineseunitindex]
+ Strchinesecurrency;
Iszero = false;
}
// Zero-Digit Processing
Else {
// Metadata processing (single digit)
If (chineseunitindex = 2 ){
// The segment contains numbers
If (doubmoneynumber> 0 ){
Strchinesecurrency = arrchineseunit [chineseunitindex]
+ Strchinesecurrency;
Iszero = true;
}
}
// Processing of tens of thousands or hundreds of millions of digits
Else if (chineseunitindex = 6 | chineseunitindex = 10 ){
// The segment contains numbers
If (doubmoneynumber % 1000> 0)
Strchinesecurrency = arrchineseunit [chineseunitindex]
+ Strchinesecurrency;
}
// Non-zero processing of the previous Digit
If (! Iszero ){
Strchinesecurrency = arrchinesenum [0]
+ Strchinesecurrency;
}
Iszero = true;
}
Doubmoneynumber = math. Floor (doubmoneynumber/10 );
Chineseunitindex ++;
}
// Negative number processing
If (bnegative)
Strchinesecurrency = "negative" + strchinesecurrency;
} Catch (exception e ){
}
Return strchinesecurrency;
}
}