Commit e59bbe2f authored by diana.alkateeb's avatar diana.alkateeb

Add IsPalindrome Task

parent fbac4896
package task;
public class TaskIsPalindrome extends TaskImpl{
@Override
public void execute() {
try {
int n = Integer.valueOf(input);
result = palindrome(n);
} catch (Exception e) {
result = "Exception: " + e.getMessage();
}
}
private String palindrome(int n) {
int temp_n=n;
int reversed_n = 0;
while (temp_n > 0) {
reversed_n = reversed_n * 10 + temp_n % 10;
temp_n = temp_n / 10;
}
if (n == reversed_n){
return ("Is Palindrome");}
else{
return ("Is Not Palindrome");}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment