/* Password.java * Author: Anders * * Translated by: Jesper * * Execise 8: * Checks if a password has a * length between 4 and 9 or not */ import cs1.Keyboard; public class Password{ public static void main(String[] args){ // The password is read from the keyboard System.out.print("Type in a password: "); String password = Keyboard.readString(); // The password is checked and the result printed int plength=password.length(); if (plength>4 && plength<9) System.out.println("The password length is correct"); else System.out.println("The password length is incorrect"); //Alternative solution /* if (plength <= 4) System.out.println("The password length is less than or equal to 4"); else if (plength >= 9) System.out.println("The password length is greater than or equal to 9"); else System.out.println("The password length is correct"); */ } // End of the main method } // End of the class