Created
December 17, 2011 14:17
-
-
Save frg/1490313 to your computer and use it in GitHub Desktop.
Debugging chris's PalindromeCheck code.
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
import javax.swing.JOptionPane; | |
import java.lang.String; | |
public class PalindromeCheck | |
{ | |
public static void main(String[]args) | |
{ | |
String terminate = "exit"; | |
String wordOne = ""; | |
boolean exit = false; | |
do | |
{ | |
wordOne =JOptionPane.showInputDialog(null,"Please Enter A Word/Phrase","INPUT",JOptionPane.QUESTION_MESSAGE); | |
if (terminate.equalsIgnoreCase(wordOne)) | |
{ | |
exit = true; | |
} | |
if ((wordOne!="") && (exit == false)) | |
{ | |
String wordTwo = wordOne; | |
StringBuffer wordRev = new StringBuffer(wordTwo); | |
if(wordOne.equalsIgnoreCase(wordRev.reverse().toString())) | |
{ | |
JOptionPane.showMessageDialog(null, wordOne+ " IS A PALINDROME"); | |
} | |
else | |
{ | |
JOptionPane.showMessageDialog(null, wordOne+ " IS NOT A PALINDROME"); | |
} | |
} | |
} while(exit == false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment