Está correta a maneira que fiz? Como posso melhorar meu código??
import java.util.Random;
import java.util.Scanner;
public class Desafio {
public static void main(String[] args) {
Scanner dados = new Scanner(System.in);
int numeroAleatorio = new Random().nextInt(100);
String mensagem1 = """
Adivinhe o número que estou pensando!!!
Você tem 5 tentativas...
""";
int numeroTentativas = 1;
System.out.println(mensagem1);
for (int tentativas = 0; tentativas < 5 ; tentativas++) {
int chute = dados.nextInt();
if (chute == numeroAleatorio) {
System.out.println("Parabéns você acertou!!!");
break;
}
if (chute > numeroAleatorio) {
System.out.println("É menor, tente novamente...");
}
if (chute < numeroAleatorio) {
System.out.println("É maior, tente novamente...");
}
numeroTentativas++;
}
System.out.println("Você gastou " + numeroTentativas + " tentativas.");
}
}