Java Programs

Write a Java program to find Armstrong number?


/*Java Program to find armstrong number*/
public class ArmStrongNumber {
     public static void main(String[] args) {        
           int num = 153; /* Give input here*/
           int rem,sum =0;
           int n=num;
           while(num > 0 ){
                 rem = num % 10;
                 sum = sum+rem*rem*rem;
                 num = num/10;
           }
           if(sum == n){
                System.out.println("Given Number is ArmStrongNumber");
           }
           else{
                System.out.println("Not ArmStrongNumber");
           }
          
     }
}
www.000webhost.com