Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Exc2VowelsCount {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- input = input.toLowerCase();
- System.out.println(vowelsCount(input));
- }
- private static int vowelsCount(String input) {
- int count = 0;
- for (int i = 0; i < input.length(); i++) {
- if (input.charAt(i)== 'a' || input.charAt(i)==('e')
- ||input.charAt(i)==('i')
- ||input.charAt(i)==('o')
- || input.charAt(i)==('u'))
- {
- count++;
- }
- }
- return count;
- }
- }
- //Write a method that receives a single string and prints the count of the vowels. Use appropriate name for the method.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement