Java program to find Armstrong number using while loop

Java program to find Armstrong number using while loop. In the java programming language, check whether the number is an armstrong number or not. This software will determine whether or not the number is an armstrong number. To print the armstrong number in the output of a java program for beginners.

class Main
{ 
public static void main(String[] args) 
{ 
int d=0,arm,temp; 
int n=154;
temp=n; 
while(n>0) 
{ 
arm=n%10; 
n=n/10; 
d=d+(arm*arm*arm); 
} 
if(temp==d) 
System.out.println("armstrong number"); 
else 
System.out.println("Not armstrong number"); 
} 
}

Output:

154 Not armstrong number