Assignment #64

Code

    ///jack newsom
///period 5
///prog PinLockout
///filename PinLockout
///date completed 10/7/15

import java.util.Scanner;

public class PinLockout
{
    public static void main( String[] args)
    {
        Scanner bot = new Scanner(System.in);
        int pin = 12345;
        int tries = 0;
        
        System.out.println("Welcome to the Dank Bank.");
        System.out.println("Enter your pin: ");
        int entry = bot.nextInt();
        tries++;
        
        while ( entry != pin && tries < 3 )
        {
            System.out.println("\nIncorrect PIN. Try again.");
            System.out.println("Enter your PIN: ");
            entry = bot.nextInt();
            tries++;
        }
        
        if (entry == pin )
            System.out.println("\nPIN accepted. You now have access to your account.");
        else if ( tries >= 3 )
            System.out.println("\nYou have run out of tries. Account locked.");
    }
}  
    

Picture of the output

Assignment X