import java.util.Scanner;

public class ValidationExample {
    
    public static void main(String args[]) {
        Scanner myScanner = new Scanner(System.in);
        
        System.out.println("Please enter a username (3 to 16 characters)");
        
        String name = myScanner.next();
        while (name.length() < 3 || name.length() > 16) {
            System.out.println("That name is not valid. It's too " + (name.length() < 3 ? "short" : "long"));
            System.out.println("Please enter a valid one (3 to 16 characters)");
            
            name = myScanner.next();
        }
        System.out.println("Your valid username is '" + name + "'");
    }
   
}