I have the following code used in my program:
do {
if (numOfItems == 3 || numOfItems == 5 || numOfItems == 7 || numOfItems == 9) {
addItems(numOfItems);
} else {
System.out.println("That number is out of range.");
System.out.println("Please choose an odd number in the range of [1, 10] exclusively:");
numOfItems = scan.nextInt();
}
} while (numOfItems != 3 || numOfItems != 5 || numOfItems != 7 || numOfItems != 9);
which, when run, keeps repeating the method which I only want to happen once. How to I make the loop keep repeating for validation, but only run the method once?