Answer:
Step-by-step explanation:
import java.util.Scanner;
public class PalindromeCheck
{
public static void palindromeCheck()
{
String someWord=" ";
int count=0;
int total=0;
System.out.println("Ënter some words entered by whitespace");
Scanner keyboard =new Scanner(System.in);
String[] words=keyboard.nextLine().split(" ");
for(int i=0;i<words.length;i++)
{
boolean flag=true;
int l=words[i].length();
for(int j=0;j<=l/2;j++)
{
if(words[i].charAt(j)!=words[i].charAt(l-j-1))
{
flag=false;
break;
}
}
if(flag)
count++;
}
System.out.println("There are "+count+" palindromes out of "+words.length+" words");
keyboard.close();
}
public static void main(String[] args)
{
palindromeCheck();
}
}
Output
Ënter some words entered by whitespace
This is a malayalam.
There are 3 palindromes out of 4 words