Computer Science, asked by dtujb, 8 months ago

write a program in java to enter a number and check whether it is an armostrong number or not. ( an Armstrong number is that inbthe sum of the cubes of its digits is equal to the number).​

Answers

Answered by AjayKumarr676
5

import java.util.*;

public class Armstrong

{

public static void main(String args[ ])

{

Scanner in = new Scanner(System.in);

int n,a,num,s=0;

num=n;

System.out.println("Enter the number");

n=in.nextInt();

while(n>0)

{

a=n%10;

s=s+a*a*a;

n=n+10;

}

if(num==s)

System.out.println("The number"+num+"is an Armstrong Number");

else

System.out.println("The number"+num+"is not an aArmstrong number");

}

}

Similar questions