Write a program in Java to check automorphic
Answers
println(number+" is not a automorphic number"); } } public static void main(String args[])
...
Implementation of this concept is shown below :
◾import java. util. Scanner;
◾class example.
◾{
◾static void check(int number)
◾{
◾int unit_digit1=number%10;
◾int square=number*number;
◾int unit_digit2=square%10;
_____________________________
hope it helps you..⭐⭐⭐
Here is your answer.
import java.util.Scanner;
public class Program {
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.");
}
}