0

I want an user to enter a word ...this program will tell the person if it is a palindrome...how do i insert joption pane code into this:

public boolean isPalindrome(int start int end)
{
   //separate case for substrings of length 0 or 1
   if (start>=end) return true;

   //get first and last character, converted to lowercase
   char first = Character.toLowerCase(text.charAt(start));
   char last = Character.toLowerCase(text.charAt(end));

   if ((Character.isLetter(first) && Character.isLetter(last))
   {
      if (first == last)
      {
         //test substring that doesn't contain the matching letters
         return isPalindrome(start +1, end -1);
      }
      else
         return false;
   }
   else if (!Character.isLetter(last))
   {
      //test substring that doesn't contain last character
      return isPalindrome(start, end -1);
   }
   else
   {
      //test substring that doesn't contain first character
      return isPalindrome(start + 1, end);
}

Edited by Reverend Jim: Fixed formatting

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by BestJewSinceJC
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.