The code is as follows:
<span style= "FONT-SIZE:18PX;" >package Test;import java.util.scanner;//will enter the floating-point money, converted into renminbi read public class Num2rmb {private static double num;private Long zheng,xiao;private string[] hanarr={"0", "one", "II", "three", "Restaurant", "WU", "Lu", "Qi", "ba", "JIU"};p rivate string[] danwei={"thousand", "Hundred", "Ten", ""};p rivate string[] jinwei={"", "Million", "billion"};p rivate int[][] temp= new int[4][18]; Converts the input amount into fractional and integer portions of private void SWP () {zheng= (Long) Num;xiao=math.round ((Num-zheng) *100);} Divides the integer part by four bits into 3 parts, does not exist the complement 0private void divide () {int i,j,k=0;for (i=0;i<3;i++) {long t1=zheng%10000;int t= (int) T1; Zheng=zheng/10000;for (j=3;j>=0;j--) {TEMP[I][J]=T%10;T=T/10;}}} Detects whether to process the current four-bit private int check (int i) {for (int j=0;j<4;j++) if (temp[i][j]!=0) return 1; return 0;} Print result private void print () {//process integer part//flag to indicate whether the current part is to handle the leading 0int i,j,k,flag=0,cnt=0,flag2=0;for (i=2;i>=0;i--) {if ( Check (i) ==0) {if (flag==1&&cnt==0) {System.out.print ("0"); cnt++;} Flag=0;continue;} Handles the leading 0for (j=0;j<4;j++) if (temp[i][j]!=0) break;flag2=1;if (j!=0&&flag==1) System.out.print ("0"), int d;//Remove the 0 at the end of the for (d=3;d>=0;d--) if (temp[i][d]!=0) break;for (k=j;k <=d;k++) {if (temp[i][k]!=0) System.out.print (Hanarr[temp[i][k]]+danwei[k]), else if (k-1>=0&&temp[i][ k-1]!=0) {System.out.print (hanarr[0]);}} flag=1; System.out.print (Jinwei[i]);} if (flag2==1) System.out.print ("Yuan"),//Processing of the decimal part if (xiao/10!=0) System.out.print (hanarr[(int) xiao/10]+ "angle"); if (xiao%10! =0) System.out.print (hanarr[(int) xiao%10]+ "min"); System.out.println ();} External run interface public void run () {SWP ();d ivide ();p rint ();} public static void Main (string[] args) {Scanner sc= new Scanner (system.in); System.out.println ("Please enter the amount of money:"); while (Sc.hasnext ()) {num = sc.nextdouble (); NUM2RMB nr =new num2rmb ();/*//Debug Section nr.swp (); System.out.println (nr.zheng+ "" +nr.xiao); Nr.divide (); for (int. i=2;i>=0;i--) {for (int j=0;j<4;j++) System.out.print (Nr.temp[i][j]); System.out.println ();} Nr.print (); */nr.run (); System.out.println ("Please enter the amount of money:");}}} </span>
Java program---Convert a floating-point number into renminbi reading method