|
can u compare this code which is my current code to the second code from my orignal post and tell me if im on the right track to cracking this?
-----------------------------------------
// Check to see if an input string is a palindrome
// orig is the original string,
// processed is the string after removing all characters
// that are not letters and converting to upper case.
import java.util.Scanner;
public class PalindromeCheck
{
private static void main(String argv)
{
String orig, processed, letter;
int left, right;
Scanner con = new Scanner(System.in);
System.out.println("Enter a string:");
orig = con.next;
for(i = 0; i < orig.length( ); i++)
{
letter = orig.charAt(i);
if (Character.isLetter(letter))
processed += Character.toUpperCase( );
}
if (processed.length( ) < 0);
{
left = 0;
right = processed.length( );
while (left < right)
{
if (processed.charAt(left) != processed.charAt(right))
System.out.println("String is not a palindrome.");
else
System.out.println("String is a palindrome.");
left++;
right--;
}
System.out.println("String is a palindrome.");
}
}
}
|