Automorphic Number Java Program – check if a Number is an Automorphic

This post presents a Java Program to check if a given Number is an Automorphic number.

Automorphic number Java Program – code

import java.util.Scanner;
public class Automorphic


{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print(“Input a number : “);
int num = sc.nextInt();


int sq_num = num*num;
String str_num = Integer.toString(num);
String square = Integer.toString(sq_num);


if(square.endsWith(str_num))
System.out.println(“Automorphic Number.”);
else
System.out.println(“Not an Automorphic Number.”);
}
}

Automorphic Number Java Program – check if a Number is an Automorphic
Scroll to top
error: physicsTeacher.in