Write a program to accept a number, check and print whether it is an Armstrong number or not. An Armstrong number is
a number that is equal to sum of the cubes of its individual digits. eg. 153=1^3
+5^3
+3^3..
Do it by Scanner in java and I will merk you BRAINLIEST surely
Answers
Answered by
0
Answer:
import java.util.*;
class Armstrong
{
public void main ()
{
Scanner sc = new Scanner (System.in);
System.out.println("Enter a number: ");
int n = sc.nextInt();
int rem,rev = 0;
for(int i = n;i > 0;i/=10)
{
rem = i%10;
rev = rev+rem*rem*rem;
}
if(n == rev)
{
System.out.println("Armstrong Number");
}
else
{
System.out.println("Not Armstrong Number");
}
}
}
I hope you find it useful... If you have any query do comment, I will try to solve it...
Similar questions