Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.  
  6.  
  7. public static void main(String[] args) {
  8. Scanner sc = new Scanner(System.in);
  9. String str = sc.nextLine();
  10. //boolean checkSpace = false;
  11. String vowels = "AEIOUYaeiouy";
  12. String unvowels = "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxz ";
  13. int counter = 0; int wordCounter = 0;
  14. for (int i = 0; i < str.length(); ++i) {
  15. /* if (str.charAt(i) == ' ') {
  16. checkSpace = true;
  17. continue;
  18. }*/
  19. if (str.charAt(i) != ' ')
  20. {
  21.  
  22. int checkValue = 2;
  23. for (i = i; i<str.length() && str.charAt(i) != ' '; ++i) {
  24. if (checkValue != 3) {
  25. if (unvowels.indexOf(str.charAt(i))!=-1) {
  26. if (checkValue == 1) {
  27. checkValue = 3;
  28. } else
  29. checkValue = 1;
  30. }
  31. if (vowels.indexOf(str.charAt(i))!=-1) {
  32. if (checkValue == 0) {
  33. checkValue = 3;
  34. } else
  35. checkValue = 0;
  36. }
  37. }
  38. System.out.print(" value: "+(str.charAt(i)));
  39. System.out.println("; check: "+checkValue);
  40. }
  41. wordCounter++;
  42. if (checkValue == 1 || checkValue == 0) {
  43. counter++;
  44. }
  45. }
  46.  
  47. }
  48. System.out.println();
  49. System.out.println(counter);
  50. System.out.println(wordCounter);
  51.  
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement