Un si la condición se tendrá en cuenta

sim:

Este bit del código se supone que debe comprobar si la longitud de la contraseña es buena, butif la longitud de la contraseña es mayor o igual a 16, se salta la condición if y imposible imprimir la frase.

/* This bit of the coe just checks the length of the password */
if (Password.length() >= 8) {
    if (Password.length() <= 10) {
        System.out.println("Medium length of password");
    }
}
else if (Password.length() < 8) {
    System.out.println("Bruv youre asking to be hacked");
} 
else if (i >= 10) {
    if (Password.length() <= 13) {
        System.out.println("Good password length");
    }
    /* The part that fails */
    else if (Password.length() >= 16) {
        System.out.println("Great password length");
    }        
} 

El código debe ser la salida "Gran longitud de la contraseña" si la longitud de la contraseña es mayor que o igual a 16 pero, duerma nada de salida si es mayor o igual de han OT 16

Eran :

if(Password.length() >= 8)y else if(Password.length() < 8)cubrir todas las posibles longitudes de contraseña, por lo que nunca se llegó a las siguientes condiciones.

Usted debe organizar sus condiciones de manera menos confusa:

if (Password.length() < 8) {
    System.out.println("Bruv youre asking to be hacked");
} else if (Password.length() >= 8 && Password.length() <= 10) {
    System.out.println("Medium length of password");
} else if (Password.length() > 10 and Password.length() <= 13) {
    System.out.println("Good password length");
} else if (Password.length() > 13 && Password.length() < 16) {
    ... // you might want to output something for passwords of length between 13 and 16
} else {
    System.out.println("Great password length");
}

o mejor

if (Password.length() < 8) {
    System.out.println("Bruv youre asking to be hacked");
} else if (Password.length() <= 10) {
    System.out.println("Medium length of password");
} else if (Password.length() <= 13) {
    System.out.println("Good password length");
} else if (Password.length() < 16) {
    ... // you might want to output something for passwords of length between 13 and 16
} else {
    System.out.println("Great password length");
}

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=230736&siteId=1
Recomendado
Clasificación