Assignemnt #64 PIN Lockout
Code
Name: Iaroslav Titov
Period: 7
Project Name: PinLockout
File Name: PinLockout.java
Date: 11/10/2015
import java.util.Scanner;
public class PinLockout
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int pin = 54321;
int tries = 0;
int maxTries = 4;
System.out.println("WELCOME TO THE IARIK'S BANK.");
System.out.print("ENTER YOUR PIN: ");
int entry = keyboard.nextInt();
tries++;
while ( entry != pin && tries < maxTries )
{
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 VAULT.");
else if ( tries >= maxTries)
System.out.println("\nYOU HAVE RUN OUT OF TRIES, SO NOW YOU ARE UNDER ARREST.");
}
}
Picture of the output