Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String str = sc.nextLine();
- //boolean checkSpace = false;
- String vowels = "AEIOUYaeiouy";
- String unvowels = "BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxz ";
- int counter = 0; int wordCounter = 0;
- for (int i = 0; i < str.length(); ++i) {
- /* if (str.charAt(i) == ' ') {
- checkSpace = true;
- continue;
- }*/
- if (str.charAt(i) != ' ')
- {
- int checkValue = 2;
- for (i = i; i<str.length() && str.charAt(i) != ' '; ++i) {
- if (checkValue != 3) {
- if (unvowels.indexOf(str.charAt(i))!=-1) {
- if (checkValue == 1) {
- checkValue = 3;
- } else
- checkValue = 1;
- }
- if (vowels.indexOf(str.charAt(i))!=-1) {
- if (checkValue == 0) {
- checkValue = 3;
- } else
- checkValue = 0;
- }
- }
- System.out.print(" value: "+(str.charAt(i)));
- System.out.println("; check: "+checkValue);
- }
- wordCounter++;
- if (checkValue == 1 || checkValue == 0) {
- counter++;
- }
- }
- }
- System.out.println();
- System.out.println(counter);
- System.out.println(wordCounter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement