/* Password2.java * Author: Kris * Translated by: Ida * Exercise 12 for the 4th week * Reads in a password and checks that the length is between 4 and 9. * Keeps polling until the password meets the criteria. */ import cs1.Keyboard; public class Password2 { public static void main(String[] args) { boolean ok=false; do { //Password is read System.out.print("Write a password: "); String password = Keyboard.readString(); //Password is checked and the result is printed int plength=password.length(); if (plength>4 && plength<9) {System.out.println("The length of the password is correct"); ok = true;} else System.out.println("The length of the password is incorrect"); } while (!ok); } } //end of class