Search This Blog

Sunday 16 October 2016

TO FIND ARMSTRONG NUMBER

import java.io.*;
class armstrong_number
{
 
      public static void armstrong() throws IOException
    {
        int r,p,sum=0;
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in) );
        System.out.println("please enter the number");
      int  n=Integer.parseInt(br.readLine());  
      int no=n;
      while(n>0)
        {
            r=n%10;
            p=r*r*r;
             sum=sum+p;
            n=n/10;
          
        }
    
        if(sum ==no)
       {
           System.out.println("the no. is armstrong no.");
        }
       else
       {
           System.out.println("the no. is not a armsrong no.");
    }
}
}

No comments:

Post a Comment

Make a JAVA program for a Toystore. This program suggest the toy based on the inputs users gives like age , gender , etc

 //editor used - IntelliJ IDEA package ToyStore; import javax.swing.*; import java.awt.event.*; import java.util.Scanner; //here you can edi...