Java implements lowercase amounts to uppercase algorithm

Source: Internet
Author: User

I wrote one in C + +, the code is not around.

However, you can be prompted, the amount of 4 bits, such as 1234567 can be divided into 1234 and 567. In addition, the number of 0 in the middle must be written 0, but to pay attention to a number of zero situation. How to write specifically you can ask the person who does the finance.

---------------------------------------------------------------

I've written it before.

Give me some ideas.

First, divide the number into decimal numbers.

If the integer 100909 should be 100,909

has an array

One: 0, one, two, three, four, five, six, seven, eight, nine

One: Yuan, jiao, Min, Li

One: Yuan, 10, hundred, Thousand, million, 10, hundred, Thousand, billion

And then we'll take it.

100909

The top will spell out

100,909 yuan

You meet the million, two 0 become a

---------------------------------------------------------------

There is a more stupid point:

Determines each character, and then the condition if (c.equals ("1")) {...}

And so forth ....

---------------------------------------------------------------

http://www.csdn.net/Develop/Read_Article.asp?Id=15823

---------------------------------------------------------------

From the CSDN to organize five programs, please refer to:

1, (Java)

public static string Numtochinese (string input) {
String s1= "0 A three Woolu qi Ba Nine";
String s4= "Corner of the whole element to pick up hundred thousand hundred thousand million";
String temp= "";
String result= "";
if (input==null) return "input string is not a number string can only include the following characters (´0´~´9´,´.´), the maximum input string can only be accurate to thousand billion, only two decimal points!" ";
Temp=input.trim ();
float F;
try{
F=float.parsefloat (temp);
}catch (Exception e) {return "input string is not a numeric string can only include the following characters (´0´~´9´,´.´), the maximum number of input strings can only be accurate to thousand billion, only two decimal points! ";}
int len=0;
if (Temp.indexof (".") ==-1) len=temp.length ();
Else Len=temp.indexof (".");
if (Len>s4.length ()-3) return ("Input string maximum can only be accurate to thousand billion, only two decimal points!") ");
int n1,n2=0;
String num= "";
String unit= "";
for (int i=0;i<temp.length (); i++) {
if (i>len+2) {break;}
if (I==len) {continue;}
N1=integer.parseint (string.valueof (Temp.charat (i)));
Num=s1.substring (n1,n1+1);
n1=len-i+2;
Unit=s4.substring (n1,n1+1);
Result=result.concat (num). concat (unit);
}
if ((Len==temp.length ()) ¦¦ (Len==temp.length ()-1)) Result=result.concat ("integer");
if (Len==temp.length ()-2) Result=result.concat ("0 points");
return result;
}

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.