Design and Develop a java program to find whether the given number is Armstrong or not.
Program Code:
import java.io.*;
public class Arm
{
public static void main(String args[])
{
int k=Integer.parseInt(as[0]);
int n=k,d=0,s=0;
while(n>0)
{
d=n%10;
s=s+(d*d*d);
n=n/10;
}
if(k==s)
System.out.println("Armstrong number”);
else
System.out.println("Armstrong number”);
}
}
Output
153
Armstrong number
Post A Comment:
0 comments: