vendredi 31 janvier 2020

How do I write an "If/else Statement" to condicionate the answer for the user?

I am having trouble writing an if/else statement that conditionate the answer of the user. I am asking the user to enter a number between 1 and 8, if the user enters a number between that range the answer will be storage on a variable, if the answer it is outside the range the program will say something like: "Invalid position." Something like this:

System.out.println("Choose a number (Between 1 to 8)");
if(---------------){
ubNum = input.nextInt();
}else{
System.out.println("Enter a valid number please");
}

What do I need to put in the if statement to accomplish it?

Aucun commentaire:

Enregistrer un commentaire