Counting Vowels Consonants Words in Strings with Java

Day 22 of Programming – String Problems Today I practiced some basic but important String-based problems that help strengthen logic building and text processing skills. 🔹 Topics Covered: • Count Vowels in a String • Count Consonants in a String • Count Words in a Sentence 💡 1️⃣ Count Vowels Vowels in English are: a, e, i, o, u Example: Input: programming Output: Vowels = 3 Logic: Traverse through the string and check if each character is a vowel. 💡 2️⃣ Count Consonants Consonants are all letters except vowels. Example: Input: programming Output: Consonants = 8 Logic: Check if the character is an alphabet but not a vowel. 💡 3️⃣ Count Words in a Sentence This problem helps in understanding string traversal and space detection. Example: Input: "Java is very powerful" Output: Words = 4 Logic: Count the number of spaces and add 1 to get the total number of words. #Java #Programming #Strings #CodingJourney #LearningToCode #Developers

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories