Answers for "count and display the number of vowels on your name java"

0

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();
    }
}
Posted by: Guest on March-15-2022

Code answers related to "count and display the number of vowels on your name java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language