import java.util.Scanner;
public class JuegoAdivinanza {
public static void main(String[] args) {
int numeroAleatorio=(int) (Math.random()*100)+1;
int cont=0;
Scanner re=new Scanner(System.in);
String mensajePrincipal= """
Juego de adivinanza.
Sr Usuario, ingrese un valor numerico entre 1 - 100
Solo se aceptan valores numericos y positivos.
Buena suerte.
""";
System.out.println(mensajePrincipal);
System.out.println(numeroAleatorio);
do {
System.out.println("INGRESE UN NUMERO: ");
int valorIngresado =re.nextInt();
if(valorIngresado >0 && valorIngresado <=100) {
cont++;
if (valorIngresado == numeroAleatorio) {
System.out.println();
System.out.println("FELICIDADES A GANADO!");
System.out.println("TOTAL INTENTOS: " + cont);
break;
}
else
{
String msj= valorIngresado>numeroAleatorio?msj=("MENOR"):("MAYOR");
System.out.println();
System.out.println("INTENTO FALLIDO!");
System.out.println("EL NUMERO INGRESADO DEBE SER "+ msj);
if(cont==5){
System.out.println();
System.out.println("LO SIENTO HA PERDIDO :(");
}
}
}
else{
System.out.println();
System.out.println("INGRESE VALORES POSITIVOS, NO SE CONTABILIZARA INTENTO.");
}
}while(cont<5);
}
}