-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay-04-Java-Q26
More file actions
64 lines (44 loc) · 1.31 KB
/
Day-04-Java-Q26
File metadata and controls
64 lines (44 loc) · 1.31 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*Sanjay wants to know whether the user input is Automorphic number or not.
For example,
The Automorphic number is square of the number ends with the Same number.
Square of 5 is 25,its ends with the value of 5.
so the number 5 is Automorphic Number.
could you please help him to find it and implements in program.
Input Format
Input consists of one integer
Constraints
Given N is greater than 1 and lesser than 9.
Output Format
Print the statement whether the given number is "Automorphic Number" or "Not Automarphic Number".
Sample Input 0
5
Sample Output 0
The Number 5.0 is Automorphic Number
Sample Input 1
9
Sample Output 1
The Number 9.0 is Not Automorphic Number
Sample Input 2
12
Sample Output 2
Invalid Input*/
#Answer
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n <= 1 || n > 9) {
System.out.println("Invalid Input");
} else {
int square = n * n;
if (square % 10 == n) {
System.out.println("The Number " + (float)n + " is Automorphic Number");
} else {
System.out.println("The Number " + (float)n + " is Not Automorphic Number");
}
}
}
}
}