import java.util.Scanner; public class Demo3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); String x; System.out.print("Enter a word: "); x = input.next(); if ( isWordPalindrome(x) ) System.out.println(x + " is a palindrome"); else System.out.println(x + " is NOT a palindrome"); } public static boolean isWordPalindrome(String s) { boolean isPalindrome = true; int i, last; last = s.length() - 1; for ( i = 0; i < s.length()/2; i++ ) { if ( s.charAt( i ) != s.charAt( last-i ) ) { isPalindrome = false; break; // We can exit the loop now } } return(isPalindrome); // Return the value } }