in Education by
write a program to enter a sentence and check if it contains palindrome words or not. if yes then count and print all palindrome words in the sentence present. Java class 10 Select the correct answer from above options

1 Answer

0 votes
by
Answer: ya sure here is your answer Explanation: /*Java program to count number of palindrome words in a sentence*/ class GFG { // Function to check if a word is // palindrome static boolean checkPalin(String word) { int n = word.length(); word = word.toLowerCase(); for (int i=0; i<n; i++,n–) if (word.charAt(i) != word.charAt(n – 1)) return false; return true; } // Function to count palindrome words static int countPalin(String str) { // to check last word for palindrome str = str + ” “; // to store each word String word = “”; int count = 0; for (int i = 0; i < str.length(); i++) { char ch = str.charAt(i); // extracting each word if (ch != ‘ ‘) word = word + ch; else { if (checkPalin(word)) count++; word = “”; } } return count; } // Driver code public static void main(String args[]) { System.out.println(countPalin(“Madam ” + “Arora teaches malayalam”)); System.out.println(countPalin(“Nitin ” + “speaks malayalam”)); } }

Related questions

0 votes
    C program to count number of words in a sentence including comma tabs Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    write a program in Java to input a number and print if it is a special number or not. do this program using ... nested and while loop . Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    icse class 10 students plzz answer this write a program to check two words are in anagram (anagram is set of ... the letters are same Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    icse class 10 students plzz answer this write a program to check two words are in anagram (anagram is set of ... the letters are same Select the correct answer from above options...
asked Dec 18, 2021 in Education by JackTerrance
0 votes
    Write a program in JAVA to input a sentence reverse every word and print . Please answer someone. Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    write a Java program to input 10 non-zero numbers in an array and display the count of even and odd numbers. URGENT! Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    write a program to read an integer and find its reverse. note: if user enter 1234 then the output should be 4321 in Python Select the correct answer from above options...
asked Dec 2, 2021 in Education by JackTerrance
0 votes
    Write a program in Java to input any age and determine whether the age is valid or  invalid. If age is ... is valid otherwise invalid. Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    Write a program to store 10 names in an array. Arrange these in alphabetical orderby sorting. Print the sorted list. ... , LUCY, etc. Select the correct answer from above options...
asked Dec 12, 2021 in Education by JackTerrance
0 votes
    Complete the sentence by choosing TWO WORDS either of which will fit the blank. The two words must both produce a ... on his bike. Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    WRITE A PROGRAM TO READ DETAILS LIKE NAME, CLASS , AGE OF A STUDENT AND THEN PRINT THE DETAILS FIRSTLY IN ... THEN IN SEPERATE LINES Select the correct answer from above options...
asked Dec 30, 2021 in Education by JackTerrance
0 votes
    Write a program in Java to print all palindromic numbers between 150-250. Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    Write a program which sends the name of a text file from the client to server and display the message on the ... file present or not. Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    hi friends hope you all are doing great Plz answer my question please do not give invalid answers Write a program ... number. Thank you Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    write a program in python to enter the mark in 3 subjects and calculate total and assign grade. If total >= 200 ... grade is B' Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
...