Answer:
Here's the code in Java with appropriate comments
Step-by-step explanation:
public static void printPalindrome(Scanner console) {
System.out.println("Word please! ");
String s = console.next();
//checking the boolean expression if true
boolean isPalendrome = true;
for (int i = 0; i < s.length() / 2; i++) {
char p = s.charAt(i);
char q = s.charAt(s.length() - i - 1);
//applying an else conditional
if (p != q) {
isPalendrome = false;
break;
}
}
//printing if we check and evaluate it to be a palindrome
if (isPalendrome)
System.out.println("Palindrome detected!");
}
Source(s):
Sun Certified Java Programmer 5.0