Import java.text.decimalformat;public class changemonney {private static final string[] str_unit = {"0", "one", "II" ", " three ", ", "WU", "Lu", "qi", "ba", "JIU"};p rivate static final string[] str_number = { "", "Pick", "Bai", "thousand", "Million", "pick", "Bai", "thousand", "billion", "pick", "Bai", "Thousand"};p ublic static void main (String[] args) {// TODO Auto-generated method stub Double d = 1234567; system.out.print (CONVERT (d)); Coin conversion Public static string convert (double d) {decimalformat dformat = New decimalformat ("#0. # # #"); String num = dformat.format (d);if (Num.indexof (".")! =-1) {string strnum = num.substring (0,num.indexOf (".")); if (Strnum.length () >12) System.out.println ("The number is too large to complete the conversion");} string point = ""; if (Num.indexof (".")! =-1) {point = "Yuan";} elsepoint = "Yuan whole"; String result = getinter (Num); return result;} Public static string getinter (string num) { //determine if a decimal point if (".") is included! =-1) {num = num.substring (0,num.indexof ("."));} Num = new stringbuffer (Num). Reverse (). toString (); Stringbuffer temp = new stringbuffer ();for (int i = 0; i < num.length (); i++) {temp.append (Str_number[i]); Temp.append (Str_unit[num.charat (i)-48]);} Num = temp.reverse (). toString (); Num = num.replace ("0 pick up", "0"); Num = num.replace ("0 bai", "0"); Num = num.replace ("0 thousand", "0"); Num = num.replace ("0", "0"); Num = num.replace ("0", "0"); return num;}}
This article is from the "Trials and hardships" blog, please be sure to keep this source http://carben.blog.51cto.com/8690350/1643544
Java to write coins into uppercase programs