Created
October 23, 2011 08:05
-
-
Save ellbur/1307035 to your computer and use it in GitHub Desktop.
Palindrome puzzle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Pal { | |
public static void main(String[] args) { | |
String word = "Racecar"; | |
word = word.toLowerCase(); | |
boolean ok = true; | |
for (int n=0; n<=word.length()-1; n++) { | |
if (word.charAt(n) == word.charAt(word.length() - n - 1)) { | |
} | |
else { | |
ok = false; | |
break; | |
} | |
} | |
if (ok) { | |
System.out.println("Yes"); | |
} | |
else { | |
System.out.println("No"); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment