Aim:- Write a program in java to check whether the number provided by the user is Armstrong.
Software used:- Notepad, Command prompt
Program coding:-
class armstrong
{
public static void main(String args[])
{
int d,n,sum=0;
n = Integer.parseInt(args[0]);
do
{
d=n%10;
n=(int)n/10;
sum=sum+d*d*d;
}
while(n>0);
n = Integer.parseInt(args[0]);
if(n==sum)
System.out.println(n+ " is Armstrong");
else
System.out.println(n+ " is not Armstrong");
}
}

0 Comments
if you have any problem, please let me know