Convert RMB numeric amount to capital amount

Source: Internet
Author: User
Public class t {public static string trans2rmb (string money) {int Index = money. indexof (". "); If (index <0) {// No cent money = money + ". 00 "; Index = money. indexof (". ");} If (money. substring (index, money. length ()). length () <3) {// No score: Money = money + "0"; Index = money. indexof (". ");} money = money. replaceall ("\ D", ""); // remove ". "int length = money. length (); // string bigletter [] = {"0", "one", "two", "three", "Si", "Wu ", "land", "Province"}; // currency unit string Unit [] = {"Province", "Province", "Pick ", "Ten Thousand", "Ten", "hundreds of millions", "Ten", "Ten ", "dimensions", "pick up", "Yuan", "angle", "points"}; stringbuffer Buf = new stringbuffer (""); For (INT I = 0; I <length; I ++) {int num = integer. parseint (string. valueof (money. charat (I); Buf. append (bigletter [num]); Buf. append (Unit [unit. length-money. length () + I]);} string moneytmp = Buf. tostring (); Buf = NULL; For (INT I = 0; I <4; I ++) {// 1234 RMB is the last of the four units, for example, 4567 (7891 million) (yuan) moneytmp = moneytmp. replaceall ("0 billion", ""); moneytmp = moneytmp. replaceall ("0 thousand", "Ten Thousand"); moneytmp = moneytmp. replaceall ("Zero errors", "zero"); moneytmp = moneytmp. replaceall ("Zero errors", "zero"); moneytmp = moneytmp. replaceall ("Zero pickup", "zero"); moneytmp = moneytmp. replaceall ("0 RMB", "RMB"); moneytmp = moneytmp. replaceall ("zero angle", "zero"); moneytmp = moneytmp. replaceall ("Zero Point", "whole");} moneytmp = moneytmp. replaceall ("hundreds of millions", "hundreds of millions"); moneytmp = moneytmp. replaceall ("", ""); moneytmp = moneytmp. replaceall ("[zero] {1,}", "zero"); // replace multiple consecutive zeros with one zero moneytmp = moneytmp. replaceall ("zero integer", "whole"); Return moneytmp;} public static void main (string [] ARGs) {string money; money = "230067890080.01"; system. out. println (trans2rmb (money); money = "230067890080.11"; system. out. println (trans2rmb (money); money = "230067890080.10"; system. out. println (trans2rmb (money); money = "230067890081.01"; system. out. println (trans2rmb (money); money = "230067890081.11"; system. out. println (trans2rmb (money); money = "230067890081.10"; system. out. println (trans2rmb (money); money = "230067890080.01"; system. out. println (trans2rmb (money); money = "230667890080.01"; system. out. println (trans2rmb (money); money = "230007890080.01"; system. out. println (trans2rmb (money); money = "230607890080.01"; system. out. println (trans2rmb (money); money = "200067890080.01"; system. out. println (trans2rmb (money); money = "200067890080.11"; system. out. println (trans2rmb (money); money = "200067890080.10"; system. out. println (trans2rmb (money); money = "200007890080.01"; system. out. println (trans2rmb (money); money = "200000890080.11"; system. out. println (trans2rmb (money); money = "200000090080.10"; system. out. println (trans2rmb (money); money = "200000000080.10"; system. out. println (trans2rmb (money); money = "200007890080"; system. out. println (trans2rmb (money); money = "200000890080.1"; system. out. println (trans2rmb (money); money = "200607890080.01"; system. out. println (trans2rmb (money); money = "200600890080.11"; system. out. println (trans2rmb (money); money = "200600090080.10"; system. out. println (trans2rmb (money); money = "200600000080.10"; system. out. println (trans2rmb (money); money = "20007800080.01"; system. out. println (trans2rmb (money); money = "10001.01"; system. out. println (trans2rmb (money); // system. out. println (new // stringbuffer (arrays. tostring (unit )). reverse (); // string small [] = {"points", ""}; // string [] Ss = new string [] {"", "Yuan"}; // system. out. println (moneyutil. trans2rmb (". "); // system. out. println (moneyutil. trans2rmb (". 0 "); // system. out. println (moneyutil. trans2rmb ("0.0"); // system. out. println (moneyutil. trans2rmb ("0.00"); // system. out. println (moneyutil. trans2rmb ("0.000"); // system. out. println (moneyutil. trans2rmb ("123456789.0"); // system. out. println (moneyutil. trans2rmb ("1234"); // system. out. println (moneyutil. trans2rmb ("1111. "); // system. out. println (moneyutil. trans2rmb ("1011.011"); // system. out. println (moneyutil. trans2rmb ("00012340000000000.011 ")); /// hundreds of millions of records are collected from each other and tens of thousands of records are collected from each other. // hundreds of millions of records are collected from each other and tens of thousands of records are collected from each other. // hundreds of millions of records are collected from each other. I want to collect tens of thousands of yuan and collect RMB at zero point. // I want to collect hundreds of millions of yuan from each other. I want to collect tens of thousands of yuan at zero point. // I want to collect hundreds of millions of yuan from each other. one minute // hundreds of millions of users are being picked up. Tens of thousands of users are being picked up. One hour is worth a whole. // hundreds of millions of users are being picked up. Tens of thousands of workers are collected. I just picked up tens of thousands of workers and collected tens of thousands of yuan and a fraction of each other. // I just picked up tens of thousands of workers and collected hundreds of millions of yuan and a fraction of each other/ /million RMB 0-9 points/0-9 points/0-9 points/0-9 points/0-9 points/0-9 points/0-9 points/0-9 points/0-9 points/ /yuan and Yuan/yuan RMB and RMB all // hundreds of millions of workers are collected, and tens of thousands of workers are collected }}

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.