Assignemnt #64 and PIN Lockout
Code
///Name: Ben Borglin
///Period: 6
///Program name: PIN lockout
///file name: PINLockout.java
///Date Finsihed: 10/21/15
import java.util.Scanner;
public class PINLockout
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int pin = 12345;
int tries = 0;
int max = 4;
System.out.println("WELCOME TO THE BANK OF JOSHUA.");
System.out.println("You have a maximum of " + max + " tries.");
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 >= 3 )
System.out.println("\nYOUR DONE KID. GET LOCKED.");
}
}
++ adds one to the variable 'n'
Picture of the output