import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int qtdMinCaracteres = 3;
String nome;
do {
System.out.print("Digite o seu nome: ");
nome = scanner.nextLine();
if (nome.length() >= qtdMinCaracteres && possuiApenasLetras(nome)) {
System.out.println("Nome " + nome + " cadastrado com sucesso!");
break;
}
System.out.println("Nome inválido. Digite novamente!");
} while (nome.length() < qtdMinCaracteres || !possuiApenasLetras(nome));
}
public static boolean possuiApenasLetras(String str) {
return str.matches("[a-zA-Z]+");
}
}