Copy Code code as follows:
/**
* Convert renminbi to Capital
*
* @param value
* @return String
*/
public static String Hangetobig (double value)
{
Char[] Hunit = {' Pick ', ' bai ', ' thousand '}; The position in the paragraph indicates
Char[] Vunit = {' million ', ' billion '}; Paragraph name indicates
char[] digit = {' 0 ', ' one ', ' II ', ' three ', ' Restaurant ', ' Wu ', ' Lu ', ' qi ', ' ba ', ' JIU '}; Digital representation
Long Midval = (long) (value * 100); To be transformed into plastic
String valstr = string.valueof (midval); Into strings
String head = valstr.substring (0, Valstr.length ()-2); Take the whole number of parts
String rail = valstr.substring (Valstr.length ()-2); Take a small number of parts
String prefix = ""; The result of partial transformation of integers
String suffix = ""; The result of the transformation of the decimal part
Handle the number after the decimal point
if (Rail.equals ("00"))
{//If the decimal division is divided into 0
suffix = "whole";
}
Else
{
suffix = Digit[rail.charat (0)-' 0 '] + "angle" + digit[rail.charat (1)-' 0 '] + "min"; Or we'll turn the horn into a dime.
}
Handle the number before the decimal point
char[] Chdig = Head.tochararray (); Converts an integer part into an array of characters
Char zero = ' 0 '; Sign ' 0 ' indicates that there have been 0
byte Zerosernum = 0; The number of consecutive occurrences of 0
for (int i = 0; i < chdig.length; i++)
{//loop process each number
int idx = (chdig.length-i-1)% 4; Take the position within the paragraph
int vidx = (chdig.length-i-1)/4; Take segment position
if (chdig[i] = = ' 0 ')
{//If the current character is 0
zerosernum++; 0 consecutive increments of number
if (zero = ' 0 ')
{//Flag
zero = digit[0];
}
else if (idx = 0 && vidx > 0 && zerosernum < 4)
{
Prefix + = vunit[vidx-1];
Zero = ' 0 ';
}
Continue
}
Zerosernum = 0; 0 consecutive times to clear zero
if (zero!= ' 0 ')
{//If the flag is not 0, add, for example million, billion or something
prefix + = zero;
Zero = ' 0 ';
}
Prefix + + digit[chdig[i]-' 0 ']; Convert the number to represent
if (idx > 0)
Prefix + = hunit[idx-1];
if (idx = = 0 && vidx > 0)
{
Prefix + = vunit[vidx-1]; Paragraph end position should be added to the paragraph name million, billion
}
}
if (prefix.length () > 0)
Prefix + = ' round '; If the integer part exists, then the words with the circle
return prefix + suffix; Returns the correct representation of
}