Assignemnt #64: Controlling Password attempts with Loops

Code

     /// Name: Sean Harrison
    /// Period: 7
    /// Program name: PINLockout
    /// File Name: PINLockout.java
    /// Date Finished: 12/9/2015
    
import java.util.Scanner;

public class PINLockout
{
    public static void main( String[] args )
    {
        Scanner keyboard = new Scanner (System.in);
        int pin =12345;
        int tries, maxTries;
        tries = 0;
        maxTries = 4;
        
        
        System.out.println( "Welcome to Community Bank N.A. " );
        System.out.print("Enter your PIN Please " );
        int entry = keyboard.nextInt();
        
        tries++;
        
        while ( entry != pin && tries < maxTries )
        {
            System.out.println( "\nIncorrect PIN. Please Try Again. " );
            System.out.print( "Enter your PIN Please " );
            entry = keyboard.nextInt();
            tries ++;
        }
        if ( entry == pin )
            System.out.println( "\nPIN Accepted. You may now proceed. " );
        else if ( tries >= maxTries )
            System.out.println( "\nYou have used up all of your 4 attempts. Acess denied on this terminal " );
        }
    }
        
          
 

Picture of the output

Assignment 64