Sugerencias, comentarios, feedback
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// create a program that simulates a guessing game. The program
// must generate a random number between 0 and 100, and ask the user to try
// to guess that number in a maximum of 5 attempt.
// On each attempt, the program must report whether the number entered by
// user is greater or less than the generated number.
int random = new Random().nextInt(100);
int attempt = 5;
Scanner scn = new Scanner(System.in);
System.out.println("Intenta adivinar el número secreto, tienes 5 intentos");
while(attempt > 0){
System.out.println("Ingresa el número que creas que es");
int number = scn.nextInt();
if(number == random){
System.out.println("Felicidades, ganaste el juego");
}else{
if(number > random){
System.out.println("El numero es menor");
}else{
System.out.println("El numero es mayor");
}
System.out.println("Intenta de nuevo");
attempt--;
}
}
System.out.println("Has perdido!");
}
}