Professional Documents
Culture Documents
Topic: String
Step-by-step
Step 1 of 3:
Palindrome Number: A palindrome string is a word that reads the same forward as
backward. In other words, if the order of the letters is reversed in a palindrome, it will
still be the same word or phrase. Examples of palindromic words are radar, level, and
civic.
Explanation: The forward and reverse order of the palindrome string is same and the
palindrome number also shows the same behaviour.
Step 2 of 3:
Program Plan:
To create the program first take the input from the user using the Scanner class.
Create the isPalindrome() function to check that the string is palindrome or not
and use the conditional statement to use it.
Create the countVowels() and countConsonant() function to count the number of
vowels and consonants in the string. Write the isVowel() function to determine
the character is vowel or consonant.
Print the computed output.
Explanation: The program plan includes create four important functions namely
isPalindrome(), countVowels() , countConsonant() and isVowel() to produce the desired
output.
Step 3 of 3:
if (isPalindrome(inputString)) {
System.out.println("The entered string is a palindrome.");
Final Answer:
The source code of the program is given above. After entering the “radar” as input the
program generates the following output.