Write a Java program that takes as input one word W as a string (as args[0]), and checks if that word is a palindrome.
Use the function charAt(index) to get the character at the index position in the string, and use
N = W.length() to record the length of the string.
Then, create a loop that will start with index = 0 and iterate to index < N / 2, and check if W.charAt(index) equals the character W.charAt(N-1-index).
After the loop, if any two characters differ, print (W + “ is not a palindrome”); else, if all characters are
the same, print (W + “ is a palindrome”).
import java.util.Scanner;
public class A23P1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Type a word");
String W = input.nextLine();
{
int N = W.length();
for (int i = 0; i < N / 2; i++)
if (W.charAt(i) != W.charAt(N-1-i))
return false;
return false;
}
}