Want to implement renminbi capitalization, in the invoice and other scenarios to use?? 1234.56 Display as: Yi Qian bai three pick restaurant Yuan Woocher points, then look down!
This program can achieve 0 to 9999 9999 9999.994 Capital conversion, accurate to sub-
Classic test data:
0
The result you want to convert is:
Sering 0 min
1234
The result you want to convert is:
Yi Qian Bai San San pick restaurant Yuan Certer
9999
The result you want to convert is:
Jiu Qian Jiu Bai Shangyuan Certer
1234.5
The result you want to convert is:
A 0-point point
1234.9
The result you want to convert is:
0 minutes from Yuan Kok, one Thousand and three
1234.56
The result you want to convert is:
Yi Qian Bai three pick restaurant Yuan Woocher points
1234.99
The result you want to convert is:
Yi Qian Bai three pick up the Yuan corner of the nine points
1234.994
The result you want to convert is:
Yi Qian Bai three pick up the Yuan corner of the nine points
1234.999
The result you want to convert is:
One and a three to pick up dollar Certer
999999999999.999
The result you want to convert is:
The data is too large to convert, please re-enter!
The program source code is as follows, including comments:
PackageCom.tfj.algorithm;ImportJava.util.Scanner; Public classRenmingbi {Private BooleanZero; String[] Strhan= {"0", "one", "II", "three", "the", "WU", "Lu", "Qi", "ba", "JIU" }; String[] Moneycount= {"", "Pick", "Bai", "thousand" }; Renmingbi () {Zero=false; } PrivateString[] Divide (Doubledigitalrmbvalue) { //working with integers LongIntpart = (Long) (Digitalrmbvalue); //processing decimals, converting decimals to integers, and rounding, where a decimal is rounded up to 100 should be added another layer of processing LongDecimalpart =Math. Round (Double) Math.Round ((digitalrmbvalue-intpart) * 10000)/100); //System.out.println ("Integer part:" + Intpart + "Fractional part:" + (Digitalrmbvalue-intpart)); if(Decimalpart = = 100) {Intpart+ = 1; } //System.out.println ("rounded up after the integer part is:" + Intpart + "Fractional part is divided into:" + Decimalpart);String Strintpart= ""; if(Intpart = = 0) Strintpart= "0"; Else{Strintpart= "" +Intpart; } String Strdecimalpart= ""; if(Decimalpart < && decimalpart >= 0) Strdecimalpart= "0" +Decimalpart; Else{Strdecimalpart= "" +Decimalpart; } //when processing input is 0 if(Intpart = = 0 && decimalpart = 0) {Zero=true; } //System.out.println ("Quasi-change to string, the whole number of parts is divided into:" + Strintpart + "decimal part:" + strdecimalpart); return Newstring[] {strintpart, strdecimalpart}; } //used to convert decimal parts Privatestring Transdecimal (String str) {if("Str.equals") | | str.equals ("00")) { return"Certer"; } Else{String strresult; Char[] STRRMB =New Char[20]; STRRMB=Str.tochararray (); if(strrmb[0] = = ' 0 ' && strrmb[1] = = ' 0 ') {strresult= ""; } Else { intDM = strrmb[0]-' 0 '; intDN = strrmb[1]-' 0 '; Strresult= STRHAN[DM] + "angle" + Strhan[dn] + "min"; } returnstrresult; } } //used to convert integer parts Privatestring Transint (String str) {Char[] FIRSTFOURBITRMB =New Char[20]; FIRSTFOURBITRMB=Str.tochararray (); intLen =firstfourbitrmb.length; String strresult= ""; for(inti = 0; i < Len; i++) { /*** After opening it will be displayed in a plain, easy-to-understand format, such as 1001, will be converted to: a 0 yuan, and not: a 0 Bai 0 to pick a dollar, but I hope to get the back of this, because the invoice needs to show is the back of this **/ //if (firstfourbitrmb[i] = = ' 0 ' && i < len) {//Boolean zeroflag = false; //While (i < len && firstfourbitrmb[i] = = ' 0 ') {//Zeroflag = true; //i++; // } //if (i! = Len && Zeroflag = = True)//strresult + = "0"; //i--; //} else {//int m = firstfourbitrmb[i]-' 0 '; //strresult + = strhan[m] + moneycount[len-i-1]; // } intm = firstfourbitrmb[i]-' 0 '; Strresult+ = Strhan[m] + moneycount[len-i-1]; } returnstrresult; } PublicString Transcomb () {string[] STRTEMPRMB=NewString[2]; Doublestrvalue =0 D; Scanner SC=NewScanner (system.in); System.out.println ("Please enter a specific amount, the results will be accurate to the points:"); strvalue=sc.nextdouble (); RENMINGBI nr=NewRenmingbi (); STRTEMPRMB=nr.divide (strvalue); //Converting a decimal partString result1 = Nr.transdecimal (strtemprmb[1]); //Convert integer partString result2 = ""; intLen = strtemprmb[0].length (); if(Len > 12) return"The data is too large to convert, please re-enter!" "; Else { if(Len >= 9) {String strBit1= strtemprmb[0].substring (0, Len-8); String StrBit2= Strtemprmb[0].substring (len-8, len-4); String strBit3= Strtemprmb[0].substring (len-4, Len); String STRRESULT1= Nr.transint (strBit1) + "billion"; String STRRESULT2= Nr.transint (strBit2) + "million"; String STRRESULT3= Nr.transint (STRBIT3) + "meta"; RESULT2= strResult1 + STRRESULT2 +STRRESULT3; } Else if(Len >= 5) {String strBit1= strtemprmb[0].substring (0, len-4); String StrBit2= Strtemprmb[0].substring (len-4, Len); String STRRESULT1= Nr.transint (strBit1) + "million"; String STRRESULT2= Nr.transint (strBit2) + "meta"; RESULT2= StrResult1 +strResult2; } Else if(Len >= 1) { if(Nr.zero = =true) {result2= "0 Yuan"; } Elseresult2= Nr.transint (strtemprmb[0]) + "meta"; } returnRESULT2 +RESULT1; } } Public Static voidMain (string[] args) {Renmingbi RMB=NewRenmingbi (); while(true) {System.out.println (Rmb.transcomb ()); } }}Note: The output comment can be opened on its own for the test run results as follows:
Java implementation RMB Capital explaining