When I run the program, it works, but the test rejects it. Someone could help me? Thanks!
package fr.codegym.task.task09.task0923;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
/*
Voyelles et consonnes
*/
public class Solution {
public static char[] voyelles = new char[]{'a', 'e', 'i', 'o', 'u', 'y'};
public static void main(String[] args) throws Exception {
// écris ton code ici
BufferedReader reader= new BufferedReader(new InputStreamReader(System.in));
StringBuilder voyelles= new StringBuilder();
StringBuilder consonnes= new StringBuilder();
String input= reader.readLine();
char[] inputChar= input.toCharArray();
for (char c:
inputChar) {
if(estVoyelle(c)) voyelles.append(c).append(" ");
else consonnes.append(c).append(" ");
}
System.out.println(voyelles);
System.out.println(consonnes);
}
// La méthode vérifie si une lettre est une voyelle
public static boolean estVoyelle(char c) {
c = Character.toLowerCase(c); // Conversion en minuscules
for (char d : voyelles) // Recherche les voyelles dans le tableau
{
if (c == d) {
return true;
}
}
return false;
}
}