A good answer might be:

Yes. The main() method of the previous version of the program does this. (After a few small modifications.)


Main Loop

Here is the main part of the new program. Check that it matches the flow chart. Recall that !open means not open; that is, !true is false and !false is true.

class LoopingLock
{
  public static void main( String[] args )
  {
    int attempt = 0;
    boolean open = false;

    while ( attempt < 3 && !open )
    {
      // try a combination, setting open to "true" if correct

      attempt = attempt + 1;
    }

  }
}

QUESTION 10:

Does

while ( attempt < 3 && !open )

do what we want?