klasscho

Untitled

Feb 25th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. package com.company;
  2. import java.util.HashSet;
  3. import java.util.LinkedHashSet;
  4. import java.util.Scanner;
  5.  
  6.  
  7. public class Main {
  8. public static void ReadLine(){
  9. Boolean isNotCorrect = false;
  10. do {
  11. Scanner in = new Scanner(System.in);
  12. System.out.println("Пожалуйста, введите предложение: ");
  13. String inputLine = in.nextLine();
  14. isNotCorrect = false;
  15. if (inputLine.equals(null) || inputLine.equals(" ")) {
  16. System.out.println("Вы ввели пустое преложение. Попробуйте еще раз!");
  17. isNotCorrect = true;
  18. }
  19. System.out.println(inputLine);
  20. } while (isNotCorrect);
  21. }
  22.  
  23. public static void LineResult (int VowelsNum, int ConsonantsNum, LinkedHashSet<Character> ActualVowels = new LinkedHashSet<>(), LinkedHashSet<Character> ActualConsonants = new LinkedHashSet<>()){
  24. int i;
  25. if ((VowelsNum == 0)&&(ConsonantsNum == 0)) {
  26. System.out.println("В строке отсутвуют буквы.");
  27. }
  28. else{
  29. if (VowelsNum == 0) {
  30. System.out.println("В строке отсутвуют гласные.");
  31. }
  32. if (ConsonantsNum == 0) {
  33. System.out.println("В строке отсутвуют согласные.");
  34. }
  35. }
  36. System.out.printf("Количество гласных: %d\n", VowelsNum);
  37. System.out.printf("Количество согласных: %d\n", ConsonantsNum);
  38. }
  39.  
  40.  
  41.  
  42. public static void LineCheck (String inputLine) {
  43. HashSet<Character> Vowels = new HashSet<Character>();
  44. String Vowels$1 = "аоуэыяеёюиАОУЭЫЯЕЁИ";
  45. for (int i = 0; i < Vowels$1.length(); i++) {
  46. Vowels.add(Vowels$1.charAt(i));
  47. }
  48. HashSet<Character> Consonants = new HashSet<Character>();
  49. String Consonants$1 = "йцкнгшщзхъфвпрлджчсмтьбЙЦКНГШЩЗХЪФВПРЛДЖЧСМТЬБ";
  50. for (int i = 0; i < Consonants$1.length(); i++) {
  51. Consonants.add(Consonants$1.charAt(i));
  52. }
  53. LinkedHashSet<Character> ActualVowels = new LinkedHashSet<>();
  54. LinkedHashSet<Character> ActualConsonants = new LinkedHashSet<>();
  55. int VowelsNum = 0;
  56. int ConsonantsNum = 0;
  57. for (int i = 0; i < inputLine.length(); i++){
  58. if (Vowels.contains(inputLine.charAt(i))){
  59. VowelsNum++;
  60. ActualConsonants.add(inputLine.charAt(i));
  61. }
  62. if (Consonants.contains(inputLine.charAt(i))){
  63. ConsonantsNum++;
  64. ActualConsonants.add(inputLine.charAt(i));
  65. }
  66. }
  67. LineResult(VowelsNum, ConsonantsNum, ActualVowels, ActualConsonants);
  68. }
  69. public static void main (String[]args) throws Exception {
  70. String inputStr;
  71. ReadLine();
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment