-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPalindromeNumber.java
More file actions
33 lines (27 loc) · 934 Bytes
/
PalindromeNumber.java
File metadata and controls
33 lines (27 loc) · 934 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
30
31
32
33
import java.util.Scanner;
// List of palindrome number
public class PalindromeNumber {
public static void main(String[] args) {
try (Scanner input = new Scanner(System.in)) {
int start, end, count = 0;
System.out.print("Enter start number: ");
start = input.nextInt();
System.out.print("Enter end number: ");
end = input.nextInt();
for (int i = start; i <= end; i++) {
int temp, result = 0, remainder;
temp = i;
while (temp != 0) {
remainder = temp % 10;
result = result * 10 + remainder;
temp = temp / 10;
}
if (result == i) {
System.out.print(result + " ");
count++;
}
}
System.out.println("\n" + count);
}
}
}