0% found this document useful (0 votes)
12 views1 page

Palindrome Exception

Uploaded by

Lohith Seedella
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Palindrome Exception

Uploaded by

Lohith Seedella
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

//Smartphone collections

import java.util.*;

class PalindromeException extends Exception{


public PalindromeException(String s){
super(s);
}
}

public class Solution {

public static int evennum(int n) {


int c = 0;
int s = 0;

while (n > 0) {
c = n % 10;
s = s * 10 + c;
n = n / 10;
}

return s;
}

public static void main(String[] args) throws Exception {

Scanner sc=new Scanner(System.in);


int n=sc.nextInt();
LinkedHashSet<Integer>list2 = new LinkedHashSet<>();
for(int i=0;i<n;i++){
int num = sc.nextInt();
list2.add(num);
}

for(Integer i:list2){
int re=evennum(i);

if(i==re){
try{
throw new PalindromeException(i+ " is a palindrome");
}catch(Exception e){
System.out.println(e);
}
}
else{
System.out.println(re);
}
}

}
}

You might also like