Java Program for finding Armstrong number

Here is a simple program in java to find whether the Entered number is an Armstrong number or not
Its a two step process Using a While Loop and If Else statements..

import java.util.*;
class ArmstrongPostslush
   public static void main(String args[])
      int no, sum = 0, temp, t;
      Scanner in = new Scanner(;
      System.out.println("Enter a number");      
      no = in.nextInt();
      temp = no;
      while( temp != 0 )
         t = temp%10;
         sum = sum + t*t*t;
         temp = temp/10; 
      if ( no == sum )
         System.out.println("The number is an armstrong number.");
         System.out.println("The number is not an armstrong number.");         


Share Your Comments
Previous C# Program to Print Pyramid From Console Application
Next Java Program to print Alphabets

About author

Aamir Shaikh
Aamir Shaikh 1705 posts

<p>A Blogger, SEO Analyst and passionate Web Developer from India.<br /> Believes in hard work and continues working to achieve success.</p>

View all posts by this author →

You might also like