Complete the code segment to check whether the number is an Armstrong number or not.
Armstrong Number:
A positive number is called an Armstrong number if it is equal to the sum of cubes of its digits for example 153 = 13+53+33, 370, 371, 407, etc.
import java.util.Scanner;
public class Exercise1_4 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
int result=0;
//Use while loop check the number is Armstrong or not.
//store the output(1 or 0) in result variable.
int n2 = n;
int sum=0 , cube;
while(n2>0)
{
cube = n2%10;
sum=sum+( cube* cube* cube);
n2 = n2/10;
}
if(n == sum)
{
result = 1;
}
else
{
result = 0;
}
System.out.print(result);
}
}