Assignment #64 PIN Lockout
Code
/// Name: Koosha Kimelman
/// Period: 7
/// Program Name: PIN Lockout
/// File Name: PINLockout.java
/// Date Completed: 11/10/15
import java.util.Scanner;
public class PINLockout {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int pin, tries, max;
pin = 12345;
tries = 0;
max = 4;
System.out.println("Welcome back to the Bank of Whatever.");
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