Could you please help me to spot it out?
The result was something like this:
a I A
S m m .
package com.codegym.task.task09.task0923;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Vowels and consonants
*/
public class Solution {
public static char[] vowels = new char[]{'a', 'e', 'i', 'o', 'u'};
public static void main(String[] args) throws Exception {
// write your code here
BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
String input = rd.readLine();
ArrayList<Character> cha = new ArrayList<Character>();
for (int i=0; i<input.length(); i++ ) {
cha.add(input.charAt(i));
}
ArrayList<Character> vowels = new ArrayList<Character>();
ArrayList<Character> consonants = new ArrayList<Character>();
for (int i=0; i<cha.size(); i++) {
if (isVowel(cha.get(i))) {
vowels.add(cha.get(i));}
else {
consonants.add(cha.get(i)); }
}
for (Character v: vowels){
System.out.print(v + " ");
}
System.out.println();
for(Character c: consonants) {
System.out.print(c + " ");
}
}
// The method checks whether a letter is a vowel
public static boolean isVowel(char c) {
c = Character.toLowerCase(c); // Convert to lowercase
for (char d : vowels) // Look for vowels in the array
{
if (c == d)
return true;
}
return false;
}
}