I am making a program with which the computer chooses a number at random and you have to guess what it is, it tells you if it is greater or less than the number you have entered, but I want to make it have a finite number of attempts, so that there are an option that you don't win, the code is this, but I'm missing the finite number of attempts (all variables are declared).
adivino = (int) ((Math.random() * 100) + 1);
do{
System.out.println("INTENTO " +contador );
System.out.println("Introduzca un numero");
intento = entrada.nextInt();
if (intento<adivino){
System.out.println("El numero a adivinar es MAYOR");
}else {
System.out.println("El numero a adivinar es MENOR");
} contador++;
}while (intento != adivino);
System.out.println("ENHORABUENA, HAS ACERTADO");