Question: ```
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js"></script>

<!-- (Optional) Latest compiled and minified JavaScript translation files -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/i18n/defaults-*.min.js"></script>

<select class="selectpicker">
  <option>Mustard</option>
  <option>Ketchup</option>
  <option>Barbecue</option>
</select>

```

```

    My code is above and it isnt displayed on my website. What is the reason?

```

Answer: 
Your while condition is incorrect, `while(input < 1 || input > 20)` it is checking if number is less than 1 and greater than 20,

This problem has two parts, 1. check if input is valid number , 2. check if number is in range

```
public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        boolean validInput = false;
        do
        {
            System.out.println("Enter valid number ");
            // get user input
            String input =  sc.nextLine();

            if(isDigit(input)) {
                int inputNumber = Integer.parseInt(input);
                //check if number is in the range of 1 to 20
                boolean isInRange = (inputNumber > 1) && (inputNumber < 20);
                validInput  = true;
                if(isInRange) {
                    System.out.println(input+" is valid Number and in the range of 1 to 20");
                }
                else {
                    System.out.println(input+" is valid Number But Not in the range of 1 to 20");
                }
            }
            else {
                System.out.println(input+" is invalid Number");
            }
        }
        while (!validInput ); // continues untill valid input is entered

    }

```

Here `isDigit` method uses regular expresssion `[0-9]` to check if character is in the range of 0 to 9, you can check more on regular expressions here <https://www.w3schools.com/java/java_regex.asp>

```

    //check if input is valid number
    public static boolean isDigit(String input) {

        if (input == null || input.length() < 0)
            return false;
        input = input.trim();
        if ("".equals(input))
            return false;
        if (input.startsWith("-")) {
            return input.substring(1).matches("[0-9]*");
        } else {
            return input.matches("[0-9]*");
        }
    }

```
I've extended your `while()` to have extra logic to check if entered input is numeric value using `isNumeric()` provided by StringUtils. This function checks if the CharSequence contains only Unicode digits and hence reducing the complexity of the code having to check numeric value explicitly.

```
import java.io.*;
import java.util.*;

import static org.apache.commons.lang3.StringUtils.isNumeric;

public class Solution {
    public static void main(String[] args) throws IOException {

        int result = isDigit();
        System.out.println("Result is: " + result);
    }

    public static int isDigit() {
        // Create a Scanner object
        Scanner s = new Scanner(System.in);
        System.out.println("Enter number");
        // Accept input in String
        String input = s.next();

        /**
         * Check if input is numeric and between 1 and 20.
         * Otherwise, accept new input from user.
         */
        while (!isNumeric(String.valueOf(input))
            || Integer.parseInt(input) < 1 || Integer.parseInt(input) > 20) {
            System.out.println("Invalid number! Range should be between 1 and 20. Try     again.");
            input = s.next();
            s.nextLine();
        }

        // Return numeric value which is between 1 and 20
        return Integer.parseInt(input);
    }
}

```

Output:

```
Enter number
30
Invalid number! Range should be between 1 and 20. Try again.
-10
Invalid number! Range should be between 1 and 20. Try again.
abc
Invalid number! Range should be between 1 and 20. Try again.
10
Result is: 10

```