Program #64

Code

   
    /// Name: Afaf Nabeeha
    /// Period: 7
    /// Program Name: Pin Lockout
    /// File Name: PIN.java
    /// Date Finished: 12/11/2015 public class PIN

        import java.util.Scanner;
        
        public class Pin
        {
        	public static void main( String[] args )
        	{
        		Scanner keyboard = new Scanner(System.in);
        		int pin = 12345;
        		int tries = 0;
        		int max = 3;
        
        		System.out.println("WELCOME TO THE BANK OF AFAF.");
        		System.out.print("ENTER YOUR PIN: ");
        		int entry = keyboard.nextInt();
        		tries++;
        
        		while ( entry != pin && tries < max )
        		{
        			System.out.println("\nINCORRECT PIN. TRY AGAIN.");
        			System.out.print("ENTER YOUR PIN: ");
        			entry = keyboard.nextInt();
        			tries++;
        		}
        
        		if ( entry == pin )
        			System.out.println("\nPIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.");
        		else if ( tries >= max )
        			System.out.println("\nYOU HAVE RUN OUT OF TRIES. ACCOUNT LOCKED.");
        	}
        }
             
    

Picture of the output

Assignment 64