import java.util.Random;
import java.util.Scanner;
public class NumeroAleatorio {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int numero = new Random().nextInt(100) + 1;
int tentativas = 5;
for (int i = 0; i < tentativas; i++) {
System.out.print("Adivinhe o número: ");
int chute = scanner.nextInt();
if (chute == numero) {
System.out.println("Você adivinhou!");
scanner.close();
return;
} else if (chute < numero) {
System.out.println(" O número é maior que " + chute);
}
else {
System.out.println(" O número é menor que " + chute);
}
}
System.out.println("Você esgotou suas tentativas. O número secreto era: " + numero);
scanner.close();
}
}