Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

count vowels in java

import java.util.*;
class CountVowel
{
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter to count vowels: ");
        String input = sc.nextLine();
        String s = input.toLowerCase();
        int l = input.length();
        int c = 0;
        
        for(int i = 0; i <= l - 1; i++)
        {
            char d = s.charAt(i);
            if(d == 'a' || d == 'e' || d == 'i' || d == 'o' || d == 'u')
            {
                c++;
            }
        }
        System.out.println("Number of Vowels: " + c);
        sc.close();
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: input char java 
Java :: java how to check string is number 
Java :: java replace all not number 
Java :: swing setbounds 
Java :: java make all interfaces implement another 
Java :: java observer pattern 
Java :: java bigdecimal check less zero 
Java :: larger number in java than long 
Java :: view binding in recyclerview adapter android java 
Java :: split string 2 characters java 
Java :: java home mac 
Java :: string to byte array java 
Java :: how to summon lightning in minecraft 
Java :: remove all new line and other in string using java 
Java :: intent flag clear task 
Java :: A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution java.lang.reflect.InvocationTargetException (no error message) 
Java :: function in java 
Java :: json to hashmap java stream 
Java :: final method meaning 
Java :: java convert java.util.Date to LocalDate 
Java :: How to initialize a 2d array in Java? 
Java :: validate date java 
Java :: jpa enum as string 
Java :: map string string to java object 
Java :: main method 
Java :: timestamp with zone java 
Java :: java enums 
Java :: binary to decimal conversion in java 
Java :: intent in java 
Java :: java string to uuid 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =