My Java learning Process Control operation RMB Conversion

Source: Internet
Author: User

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

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.