Dudeney Number

Dudeney Number is a natural number which is a perfect cube and cube root is equal to the sum of its digits.

Example 1: 19683. 273 = 19683. Also 1+9+6+8+3 = 27. Hence it is a Dudeney Number.

Example 2: 74088. 423 = 74088. But 7+4+0+8+8 ≠ 42. Hence it is not a Dudeney Number.

Java
import java.util.*;
public class DudeneyNumber
{
    public static void main(String args[])
    {
        int n=0,r=0,sum=0,cRoot=0,nCopy=0;
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter a number: ");
        n=sc.nextInt();
        nCopy=n;
        cRoot=(int)Math.cbrt(n);
        while(n>0)
        {
            r=n%10;
            sum=sum+r;
            n=n/10;
        }
        if(cRoot==sum)
        {
            System.out.println(nCopy+" is a Dudeney Number");
        }
        else
        {
            System.out.println(nCopy+" is not a Dudeney Number");
        }
    }
}
Java