Super simple capital transfer-Arabic numerals to Chinese capital

Source: Internet
Author: User

Public class convertmoney {

 
Public static void main (string [] ARGs ){

System. Out. println (convert (6800000300.23d ));
}
/**
* Arabic numerals are converted to uppercase Chinese characters. Only up to digits are supported, and decimal conversions are not supported.
* @ Param ARGs
*/
Public static string convert (double N ){

Char [] d = {'0', 'yi', 'er', 'san', 'siz', 'wu', 'l', 'shanghai ', 'handler', 'handler '};
Char [] D2 = {'meta', 'pick', 'taobao', 'taobao', 'wan', 'taobao', 'taobao ', 'yi', 'pick', 'taobao', 'taobao '};

String STR = string. Format ("%. 0f", N );
Stringbuilder sb = new stringbuilder ();

System. Out. println (STR );
If (Str. Length ()> d2.length ){
System. Out. println ("the amount is too large. conversion is not supported! ");
Return NULL;
}

For (INT I = 0; I <Str. Length (); I ++ ){

SB. append (d [Str. charat (I)-'0']);
SB. append (D2 [Str. Length ()-i-1]);
}
STR = sb. tostring ();
STR = Str. replaceall ("Zero [hacker]", "zero ");
STR = Str. replaceall ("Zero {2,}", "zero ");
STR = Str. replaceall ("zero ([trillion yuan])", "$1 ");
STR = Str. replaceall ("hundreds of millions", "hundreds of millions ");

Return STR;
}
}

 

The above program output:

6800000300
Lu Zhiyi: 0 million yuan

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.