import java.io.PrintStream; import java.util.Scanner; public class Palindrome { public static void main(String[] args) { Scanner input = new Scanner(System.in); PrintStream output = System.out; boolean goOn; do { output.print("Enter word: "); String word = input.nextLine(); StringBuffer reverse = new StringBuffer(word); reverse.reverse(); boolean isPalindrome = word.equals(reverse.toString()); if (isPalindrome) { output.println("This is a palindrome"); } else { output.println("This is not a palindrome"); } output.println(); output.print("Do you want to continue? [y/n] "); String reply = input.nextLine().trim().toLowerCase(); goOn = reply.equals("y"); } while (goOn); } }