Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Methods;
- import java.util.Locale;
- import java.util.Scanner;
- public class VowelsCount_02 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String text = scanner.nextLine();
- //принтира брой на гласните букви
- printVowelsCount(text.toLowerCase());
- }
- public static void printVowelsCount (String text) {
- //a, e, i, o, u
- //"Desislava"
- int count = 0; //брой на гласните букви
- for (int position = 0; position <= text.length() - 1; position++) {
- char letter = text.charAt(position);
- if (letter == 'a' || letter == 'e' || letter == 'i' || letter == 'o' || letter == 'u') {
- //буквата е гласна
- count++;
- }
- }
- System.out.println(count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment