Java Program to Print Automorphic Numbers

In this tutorial, We will be going to Deal with Java Program to Print Automorphic Numbers Problem. We will Understand What are Automorphic Numbers and How to Implement The concept in Java.

If you are Not Aware of how to Solve Problem For printing Automorphic Numbers in java, then you’re at the Right place to Know About it from scratch.

What Are Automorphic Numbers And How to solve In Java

An Automorphic Number is a Number, Which when squared, ends with the same number as provided by the user. For example, suppose User Enters A number 5. The program should return “AUTOMORPHIC NUMBER”  since 5*5=25.

In this Code below, We are dealing with Problem Java Program to Print Automorphic Numbers.

Squared Number is Then Stored in a variable named ‘Square’.

The input method is Accepted using the nextInt method of scanner class and stored in a variable.

Initially, Create a Class named AutoMorphic with Taking input from User to check whether it is automorphic Number or it is not. After this Square that number and Store it in a Variable.

The Number original one and its square are displayed.

Now we have to check whether That number ends with the same when squared or not. Here We will check By Taking Modulus of The Square calculated and Comparing it to the original number And comparing it.

What the remainder or modulus operator does is that it extracts as a remainder exactly The same no. Digits as supplied by the user. This Check is best suitable For Checking the than concatenate String one Solution.

After the check, if the condition is satisfied, Display AutoMorphic else displays Not an Automorphic.

After Supplying An input, we get to see the Desired output as we needed.

Print Automorphic Numbers in Java

 import java.util.*;
class  AutoMorphic
     public static void main(String[] args) 
            Scanner s = new Scanner(;
            System.out.println("Enter any number");
            int n  = s.nextInt();
            int square = n* n;
            System.out.println(" Given Number : "  + n ) ;
            System.out.println("  Its Square is " + square) ;
            if( n == (square%100) || n == (square%10) ) 
                         System.out.println(n  +"is Automorphic");
                        System.out.println(n  +"is  not Automorphic");

The output for the above code is displayed below:

Print Automorphic Numbers

You may also read:

Leave a Reply

Your email address will not be published. Required fields are marked *