Import java.util.*;
Class RMB Conversion Job
{
/*****
First determine whether it is zero, not 0 normal for loop: new +unit+result;
Zero is the first to determine whether to eliminate units (as long as not million and billions of units),
Again determine whether to eliminate 0 (the previous number is nonzero, and the unit is not million and billion, the normal output),
(The previous number is zero, or the unit is million and billion, 0 omitted)
(first 0 to be eliminated)
otherwise normal output;
******/
public static void Main (string[] args)
{
The number of conversions required;
int a=210540080;
Empty string to do the link use;
String result= "";
Since the addition of result is from right to left, unit to reverse;
String[] unit= new string[]{"thousand", "Hundred", "ten", "billion", "thousand", "Hundred", "ten", "Million", "thousand", "Hundred", "ten", "" "};
String[] chineseword=new string[]{"0", "one", "two", "three", "four", "five", "six", "seven", "eight", "Nine"};
String str = a + "";
for (int i= (Str.length ()-1), J=11;i>-1;i--, j--)
{
int b= Str.charat (i);
if (b==48)
{
if (j!=3&j!=7)
{
Unit[j]= "";
}
if (i== (Str.length ()-1))
{
Note that the Add order is right-to-left at this time;
Result=unit[j]+result;
Continue
}
if (i!= (Str.length ()-1))
{
int aa= (Str.charat (i+1));
if (aa!=48&&j!=3&&j!=7)
{
Note that the Add order is right-to-left at this time;
Result=chineseword[b-48]+unit[j]+result;
Continue
}
else if (AA ==48| | j==3| | J==7)
{
Result=unit[j]+result;
Continue
}
}
}
Note that the add order is now ten right-to-left;
Result=chineseword[b-48]+unit[j]+result;
}
System.out.print (result);
}
}
This article is from the "64 Tiger" blog, be sure to keep this source http://doubletiger.blog.51cto.com/11157348/1747239
My Java learning Process Control operation RMB Conversion