Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class CountingVowels{
- public static void main(String args[]){
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter a string: ");
- String string = sc.nextLine();
- string = string.toLowerCase();
- int counter = 0;
- for(int i = 0; i < string.length(); i++)
- if(string.charAt(i) == 'a' || string.charAt(i) == 'e' || string.charAt(i) == 'i' || string.charAt(i) == 'o' || string.charAt(i) == 'u')
- counter++;
- System.out.println("The number of vowerls are "+counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement