Java implementation method for converting digital capital amounts _java

Source: Internet
Author: User

This article describes the Java implementation of the digital capitalization amount conversion method. Share to everyone for your reference. Specifically as follows:

Example: an implementation that converts the amount of an Arabic numeral to an uppercase amount in Chinese, for example:
¥1011→ 0 to pick one yuan whole.
The capital number is: 0, one, the other, three, the restaurant, Wu, Lu, QI, BA, nine, pick, Bai, Qian, million, billion

 import java.io.*; import java.lang.String; public class Change {public static void Mai
   N (String agrs[]) {//money is used to hold the amount of input long money=0;
   String mon[]={"0", "one", "II", "three", "Restaurant", "WU", "Lu", "Qi", "ba", "Nine"}; String mon1[]={"Pick Up", "Bai", "" Thousand "," Million "," Collect million "," Million "," Thousand Million "," billion "," pick billion "," billion "," Thousand Billion "}, je[]=new string[30];//je[] array for the number of digital amount converted
   n is used to test whether you have the amount converted int n=agrs.length;
   if (n==0) System.out.println ("Please enter the amount you want to convert:");    
   Converts the amount entered into a Long type of data else {Money=long.parselong (agrs[n-1]);
   //bitt is used to store the number of amounts that need to be converted, int bitt=0,j,k=-1,i=0;
   The conversion process while (money!=0) {bitt= (int) (money%10l);
   Calculates the uppercase value for (j=0;j<mon.length;j++) {if (J==bitt) break of each number;
    ///Save the corresponding value in je[] if (k!=-1) {je[i]=mon1[k];i++}    
    je[i]=mon[j];i++;
    MONEY=MONEY/10;
    k++;
     if (money==0) {//Output converted amount System.out.print ("The amount you entered is:");
     i--;
    for (; i>=0;i--) System.out.print (Je[i]); }
   }
 }
}

I hope this article will help you with your Java programming.

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.