In this part of the code, a scanner asks the user to input a number between one and five. I will need to rewrite this for a bunch of variables, so is there any way to make it shorter?
if (Q1 != 1 || Q1 != 2 || Q1 != 3 || Q1 !=4 || Q1 != 5) {
System.out.println("Error: Please enter a number between 1 and 5.");
}
Instead of typing Q1 != 1
or 2 or 3 etc, is there a way to write 1-5 or something like that?