Code Below:
// ARMSTRONG NO. PROGRAM USING RETURN FUNCTION
import java.util.*;
class returnprg1
{
public static boolean isArmstrong(int n)
{
int r,s=0,temp=n;
while (n>0)
{
r=n%10;
s=s+(r*r*r);
n=n/10;
}
return (temp==s);
}
public static void main()
{
Scanner s=new Scanner(System.in);
int n;
System.out.println("enter a no.");
n=s.nextInt();
if (isArmstrong(n))
System.out.println("Armstrong");
else
System.out.println("NOT Armstrong");
}
}