import java.io.*;
class Pal
{
public static void main(String args[])throws IOException
{
InputStreamReader reader=new InputStreamReader(System.in);
BufferedReader input=new BufferedReader(reader);
System.out.println("ENTER THE STRING");
String s=input.readLine();
char ch;
char a[]=new char[s.length()];
for(int i=0;i<=s.length()-1;i++) { ch=s.charAt(i); a[i]=ch; } boolean choice=false; for(int i=0,j=s.length()-1;j>=i;i++,j--)
{
System.out.println(a[i]+" --- "+a[j]);
if(a[i]==a[j])
choice=true;
else
{
choice=false;
break;
}
}
if(choice==true)
System.out.println("IT IS A PALINDROME");
else
System.out.println("IT IS NOT A PALINDROME");
}
}
1>Download CLASS File
2>Download SOURCE CODE
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment