Code Below:
import java.util.*;
class automorphic
{
public static void main()
{
Scanner s=new Scanner(System.in);
int n,i,sq,a,sum=0;
System.out.println("enter a no.");
n=s.nextInt();
i=n;sq=n*n;
while(i>0)
{
a=i%10;
sum++;
i=i/10;
}
if(sq%(int)Math.pow(10,sum)==n)
System.out.println("automorphic no.");
}
}