I have a project which I need to ask the user to introduce at least 5 valid full names (until 10 full names or if the user introduce "fim"). Each full name needs to have at least 2 names with 4 characters each and the full name is only valid if it doesn't exceed 120 characters. I need to create a array for each full name which the elements are the names that are part of the full name. Here I have my code yet. I have a lot of options that doesn't work in comment. "Nome Inválido" id invalid name and "Nome Válido" iS Valid Name.
public static void main(String[] args) {
Scanner keyboard = new Scanner (System.in);
System.out.println("Introduza até 10 nomes completos com até 120 caracteres e pelo menos dois nomes com pelo menos 4 caracteres: ");
String nome;
int i = 0;
do {
//nomes[i] = keyboard.next();
nome = keyboard.nextLine();
i++;
String[] nomeSeparado = nome.split(" ");
System.out.print(Arrays.toString(nomeSeparado));
int j = nomeSeparado[i].length();
/**
1) for(int k = 0; k < 2; k++) {
if(!(j == 4)) {
System.out.println(" Nome Inválido ");
}
else {
System.out.println(" Nome Válido ");
}
}
2) while( k < 2 ) {
if(!(j == 4)) {
System.out.println(" Nome Inválido ");
}
else {
System.out.println(" Nome Válido ");
}
}
3) if(while(!(nomeSeparado[i].length() == 4)<2)) {
System.out.println(" Nome Inválido ");
}
4) for(i = 0; i < 10 ; i++) {
if( j > 2 && nomeSeparado[i].length() == 4 ) {
System.out.println(" Nome Válido ");
}
else {System.out.println(" Nome Inválido ");}
}
**/
}
while(!nome.equalsIgnoreCase("fim") && i<10);
}