-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPalindromeCheckOfThreeDigit.java
More file actions
45 lines (31 loc) · 1.07 KB
/
Copy pathPalindromeCheckOfThreeDigit.java
File metadata and controls
45 lines (31 loc) · 1.07 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
//package nareshit.lab;
/*
Write a java program which print the given three digit number is palindrome or not
Program is determined by the following rules:
if the given number is an three digit number, Example: if x = 232, print 1. if x = 345, print 0
if 1 then print a message that the number is pallindrome
if 0 then print a message that the number is not a pallindrome
if the given number is negative or zero, print -1
if -1 then print a message that the given number is -ve kindly provide the +ve number only
if the given number is not an three digit number, print -2
if -2 then print the message that this program can check the operation for the 3 number only.
*/
public class PalindromeCheckOfThreeDigit {
public static void main(String[] args) {
int n=Integer.parseInt(args[0]);
int temp=n;
int sum=0;
int r=n%10;
sum+=r;
n/=10;
r=n%10;
sum+=r;
n/=10;
sum+=n;
n/=10;
if(temp==sum)
System.out.println(1);
else
System.out.println(0);
}
}