import java.util.Random;
import java.util.Scanner;
public class Adivinanza {
public static void main(String[] args) {
Random aleatorio = new Random();
Scanner teclado = new Scanner(System.in);
boolean iniciarPartida = true;
while (iniciarPartida) {
int secreto = aleatorio.nextInt(101);
int contador = 1;
System.out.println("bienvenido a adivina el numero secreto, solo tienes cindo intentos");
while (contador < 6) {
System.out.println("ingrese un número del 0 al 100");
int numero = teclado.nextInt();
if (numero == secreto) {
System.out.println(String.format("Felicidades, adivinaste! el número secreto es %d", numero));
System.out.println(String.format("Adivinaste en el intento %d", contador));
break;
} else {
if (numero < secreto) {
System.out.println("El número secreto es mayor");
} else {
System.out.println("El número secretro es menor");
}
contador++;
if(contador==5){
System.out.println("solo te queda un intento20");
}
if (contador == 6) {
System.out.println("perdiste, solo tenias cinco intentos");
System.out.println(String.format("El numero secreto era %d", secreto));
}
}
}
System.out.println("Querés jugar de nuevo? (s/n)");
String respuesta = teclado.next().toLowerCase();
if(!respuesta.equals("s")){
iniciarPartida = false;
System.out.println("gracias por jugar");
}
System.out.println();
}
teclado.close();
}
}