Computer Science, asked by heet2910, 1 year ago

write java program to find automorphic number.

Answers

Answered by qyush
6
it is correct answer?
Attachments:

animes71: u are giving the answer and u only don'no about the anawer which u ate writing
Answered by BrainlyPromoter
14

Sample program to check whether the number entered by user is automorphic:

import java.util.Scanner;

public class AutomorphicChecker

{

   public static void ch()

   {

       Scanner sc=new Scanner(System.in);

       System.out.println("Enter a number that you want to check if its automorphic.");

       int n=sc.nextInt();

       int sq=0, b=0, c=1;

       sq=n*n;

       int d=n;

       int l=n;

       while(n!=0)

       {

           b++;

           n=n/10;

       }

       for(int k=1;k<=b;k++)

       {

           c=c*10;

       }

       int dig=sq%c;

       if(dig==d)

       {

           System.out.println("Entered number is an automorphic number.");

       }

       else    System.out.println("Entered number is not an automorphic number.");

   }

}

Output:

Enter a number that you want to check if its automorphic.

25

Entered number is an automorphic number.

Attachments:
Similar questions