Re: Palindrome program help
Please do not duplicate threads...I have removed your other thread and moved this to a more appropriate location.
Re: Palindrome program help
Quote:
String input = scan.nextLine();
String strippedInput = input.replaceAll("\\W", "");
str = scan.nextLine();
What is the point of this code segment?
After you ask for a palindrome, you assign it to strippedInput and then immediately expect more input. Why?
Quote:
while (str.charAt(left) == str.charAt(right) && left < right)
{
left++;
right--;
}
System.out.println();
if (left < right)
System.out.println ("That string is NOT a palindrome.");
else
System.out.println ("That string IS a palindrome.");
What if the string has an even number of chars? i.e., "pannap" that IS a palindrome