Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main
- {
- public static void main(String[] args)
- {
- System.out.println("Введите текст");
- char[] vowel = {'а', 'е', 'ё', 'и', 'о', 'у', 'э', 'ы', 'ю', 'я'};
- char[] notVowel = {'б', 'в', 'г', 'д', 'ж', 'з', 'й', 'к', 'л', 'м', 'н', 'п', 'р', 'с', 'т', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ь'};
- System.out.println("Множество гласных букв состоит из " + vowel.length + " символов.");
- System.out.println("Множество негласных букв состоит из " + notVowel.length + " символов.");
- String userText= userInput();
- System.out.println("В вашем предложении "+vowelCounter(vowel,stringToCharArr(userText))+" гласных букв"+" и "+
- notVowelcounter(vowel,stringToCharArr(userText))+" негласных букв");
- }
- public static String userInput()
- {
- Scanner scanner = new Scanner(System.in);
- String buf = scanner.nextLine();
- String userInput = buf;
- return userInput;
- }
- public static char[] stringToCharArr(String userString)
- {
- char[] StringToCharArray = userString.toCharArray();
- return StringToCharArray;
- }
- public static int vowelCounter(char[] vowelArr,char[] userArr)
- {
- int vowelValue = 0;
- for (int x = 0; x < userArr.length; x++)
- {
- for (int y = 0; y < vowelArr.length; y++)
- {
- if (userArr[x]==vowelArr[y])
- {
- vowelValue++;
- }
- }
- }
- return vowelValue;
- }
- public static int notVowelcounter(char[] vowelArr,char[] userArr)
- {
- int notVowelValue = 0;
- for (int x = 0; x < userArr.length; x++)
- {
- for (int y = 0; y < vowelArr.length; y++)
- {
- if (userArr[x]==vowelArr[y])
- {
- notVowelValue++;
- }
- }
- }
- return notVowelValue++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement