Code is copied!
Program To Print Armstrong Number JAVA
Write a Program to print whether the inputted number is Armstrong or not.
Armstrong Number is a positive number if it is equal to the sum of cubes of its digits is called Armstrong number and if its sum is not equal to the number then its not a Armstrong number.
Examples: 153 is Armstrong
(1*1*1)+(5*5*5)+(3*3*3) = 153
import java.util.*; class armstrong { public static void main(String args[]) { Scanner sc = new Scanner (System.in); int n = sc.nextInt(); int temp =n,sum =0; while (n!=0) { int digit = n % 10; sum = sum + (digit * digit *digit); n=n/10; } if(temp == sum) { System.out.println("yes it is armstrong number"); } else { System.out.println("No it is not armstrong"); } } }