Question: I am having a user enter in a multiple of 3 between 3 and 24 inclusive. The output then prints out the number less 3 until it reaches 0. Ex the user picks 15. The output prints out 15,12,9,6,3,0. The problem is if the user picks the number 17 it rounds it down to 15 and proceeds to do the rest of the code. How do I make it repeat the input infinitely if they do not enter in a multiple of 3? My code is as follows.

```
do{
        System.out.print("Enter a multiple of 3: ");
        //We use the variable n to hold the multiple of 3, like the heading says to do.

        n = input.nextInt();
        if (n % 3 !=0 || n >= 25) {
            System.out.println("Error: Enter a multiple of 3 between 3 and 24, inclusive.");
            n = input.nextInt();                
        }
        /**
         * X = n /3, this gives us the base number of the multiple of 3 to use and figure out the
         * values of n->0 by 3's.
         */
        for(x = n / 3; x <= 8 && x >=0; x--){
            int three = 3 * x;
            System.out.printf(three + "\t");

        }

    }while(x >= 0);

```

As you can see I just put another input section within the if statement, however I do not wish to do this. I am trying to figure out a way for the if statement to keep looping. Is it my parameters I set up on my if statement? Or is there a specific command to make the if statement repeat if the criteria of the statement is not met? Also I am using Java.

Answer: 
You can use a separate loop to initialize `n`. (I'm not sure what your outer loop is for, so I deleted it.)

```
int n;

while (true) {
  System.out.print("Enter a multiple of 3: ");

  n = input.nextInt();
  // Validate input.
  if (n % 3 == 0 && n < 25 && n > 0) {
    // Input is good.
    break;
  }
  // Input is bad. Continue looping.
  System.out.println("Error: Enter a multiple of 3 between 3 and 24, inclusive.");
}

for (x = n / 3; x <= 8; x--) {
  int three = 3 * x;
  System.out.printf(three + "\t");
}

```

The `if`--`break` pattern is necessary because you need to check the looping condition in the middle of the loop, rather than the beginning or end.
If you don't like the `while(true) { ... break; ... }` then you can use a `do { ... } while (flag);` loop instead. A do/while loop is common when you want to do something 1 or more times - specifically at least once and you aren't sure how many times.

For example

```
boolean keepGoing = true;
do {
    System.out.println("Enter a multiple of 3 between 3 and 24: ");
    n = input.nextInt();
    keepGoing = (n < 3 || 24 < n || n % 3 != 0);
} while (keepGoing);
System.out.println("You entered: " + n);

```

Or this variation

```
boolean done = true;
do {
    System.out.println("Enter a multiple of 3 between 3 and 24: ");
    n = input.nextInt();
    done = (3 <= n && n <= 24 && n % 3 == 0);
} while (!done);
System.out.println("You entered: " + n);

```