Simple decomposition of positive integers in Java.

Source: Internet
Author: User

Import java.util.*;
Class Work7
{
public static void Main (string[] args)
{//Enter up to 1 billion digits
string[] str = new string[]{"10-bit", "hundred", "thousand", "million-bit", "100,000-bit", "Million Dollar", "Chiwan", "million-bit", "1 billion-bit", "ranked", "Chi"};
System.out.println ("Please enter a number");
Scanner sac = new Scanner (system.in);

Accept the number of user input
Long sum = Sac.nextint ();
Long sum2=sum;
int a=0;
for (int i = 0; i<32; i++)
{

Determine how many digits the user has entered
if (sum/10>0) {
SUM=SUM/10;
a++;
}else{

Break
}
}
if (sum2<10)
{
Long k =sum;
System.out.println ("Only bits of this number are" +k);

}else{

The number of user input is decomposed.

for (int i = 0; i<=a; i++)
{

if (i==0)
{
Long C = sum2%10;
SYSTEM.OUT.PRINTLN ("The digit of this number is" +c);


}else if (i<a) {

Here is a strong turn to this function comes out of double;
Long new1= (Long) Math.pow (ten, I);

Parameter description: M is the number of the requesting party, N is the second-party number

Long B = sum2/new1%10;
System.out.println ("The number of the first +str[i-1]+" is "+b");

}else{

Long new2= (Long) Math.pow (ten, I);
Long h = sum2/new2%10;

System.out.println ("The number of the first +str[i-1]+" is "+h");


}



}


}






}
}

Simple decomposition of positive integers in Java.

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.