Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // package javaapplication3;
- import java.util.Scanner;
- public class TestClass {
- static boolean isVowel(String ch) {
- char test = ch.toLowerCase().charAt(0);
- if (test == 'a' || test == 'e' || test == 'i' || test == 'o' || test == 'u') {
- return true;
- } else {
- return false;
- }
- }
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- // amount of case
- long CASE = sc.nextInt();
- sc.nextLine();
- for (long caseCount = 0; caseCount < CASE; caseCount++) {
- // stores how many vowels are there
- long vowelCount = 0;
- // reads the string
- String str = sc.nextLine();
- // System.out.println("STRING LEGNTH: " + str.length());
- // split into array
- String[] arr = str.split("");
- long size = arr.length;
- long init = arr.length;
- long var = 0;
- /*
- for (int a = 0; a < size / 2; a++) {
- if (isVowel(arr[a])) {
- vowelCount += init;
- }
- var += 2;
- init = init + size - var;
- // System.out.println("FIRST: " + init);
- // System.out.println("FIRST: " + arr[a]);
- }
- for (int a = (size / 2); a < size; a++) {
- // System.out.println("2ND: " + arr[a]);
- if (isVowel(arr[a])) {
- vowelCount += init;
- }
- var += 2;
- init = init + size - var;
- // System.out.println("2ND: " + init);
- }
- */
- for (long a = 0; a < size; a++) {
- if (isVowel(arr[(int)a])) {
- vowelCount += init;
- }
- var += 2;
- init = init + size - var;
- // System.out.println("FIRST: " + init);
- // System.out.println("FIRST: " + arr[a]);
- }
- System.out.println(vowelCount);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement