import java.util.Random;
import java.util.Scanner;
public class JuegoAdivinanza {
public static void main(String[] args) {
Random random = new Random();
Scanner scanner = new Scanner(System.in);
int numeroSecreto = random.nextInt(101); // número entre 0 y 100
int intentos = 0;
int maxIntentos = 5;
while (intentos < maxIntentos) {
System.out.println("Adivina el número (entre 0 y 100): ");
int numeroUsuario = scanner.nextInt();
intentos++;
if (numeroUsuario == numeroSecreto) {
System.out.println("¡Felicidades! Adivinaste el número en " + intentos + " intentos.");
break;
}
else if (numeroUsuario > numeroSecreto) {
System.out.println("El número secreto es MENOR.");
}
else {
System.out.println("El número secreto es MAYOR.");
}
if (intentos == maxIntentos) {
System.out.println("Se acabaron los intentos. El número era: " + numeroSecreto);
}
}
scanner.close();
}
}