static void start() {
Scanner sc = new Scanner(System.in);
System.out.println("\nYou're going to play a guess number game.");
System.out.println("\nPlease type in a minimum value.\n");
min = sc.nextInt();
System.out.println("\nThe value you entered is "+min);
System.out.println("\nPlease type in a maximum value.\n");
max = sc.nextInt();
System.out.println("\nThe value you entered is "+max);
if (min>max) {
System.out.print("\nYou entered a maximum value lower then the minimum value, please try again.");
start();
}else if (min>=max-9) {
System.out.print("\nYou must have a maximum be 9 more than the minimum, please try again.");
start();
}
number = (int)(Math.random() * (max - min + 1) + min);
System.out.println("\nPlease pick a number, "+min+"-"+max+".\n");
guess = sc.nextInt();
checkGuess();
}
In the code, everything works except for the if statement checking to see if the minimum value and the maximum value are at least 9 numbers apart.
I use Eclipse IDE and Java-14.
Aucun commentaire:
Enregistrer un commentaire