Assignment #64 and PIN Lockout
Code
///Name: Tim Gibson
///Period: 6
///Project Name: PIN Lockout
///File Name: PinLockout.java
///Date Finished: 10/20/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 maxtries = 4;
System.out.print( "Welcome to the bank of Tim.\nEnter 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 account." );
else if ( tries >= maxtries )
System.out.println( "\nYou have run out of tries. Account Locked." );
}
}
Picture of the output