Scanner teclado = new Scanner(System.in);
double numero = 0;
int totalIntentos = 0;
int generadorNumeroPrueba = new Random().nextInt(10);
System.out.println(generadorNumeroPrueba);
while (totalIntentos < 3) {
System.out.println("escribe un numero para que adivines cual es");
numero = teclado.nextDouble();
totalIntentos++;
if (generadorNumeroPrueba == numero) {
System.out.println("acertaste el numero en un total de:" + totalIntentos + "intentos");
break;
} else {
System.out.println("fallaste vuelve a intentar");
}
if (totalIntentos == 3) {
System.out.println("Lo siento, no conseguiste adivinar el número en 5 intentos. El número era " + generadorNumeroPrueba);
}
}