-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmar23b.java
More file actions
29 lines (29 loc) · 1009 Bytes
/
Copy pathmar23b.java
File metadata and controls
29 lines (29 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.Scanner;
public class mar23b {
public static void main(String args[]) {
Scanner keyboard = new Scanner(System.in);
String answer = "Yes";
do {
System.out.print("Enter a number to check: ");
long num = keyboard.nextInt();
long square = (long) Math.pow(num, 2.0);
long temp = num;
boolean flag = true;
while (num > 0) {
if (num % 10 != square % 10) {
flag = false;
break;
}
num = num / 10;
square = square / 10;
}
if (flag)
System.out.println(temp + " is an automorphic number.");
else
System.out.println(temp + " is not an automorphic number.");
System.out.print("Do you want to continue (yes/no)? ");
answer = keyboard.next();
} while (!answer.equalsIgnoreCase("no"));
keyboard.close();
}
}