Assignemnt #64
Code
/// Name: Sam Menar
/// Period: 6
/// Program Name: PinLockout
/// File Name: PinLockout.java
/// Date Finished: 12/16/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 SAM.");
System.out.print("ENTER YOUR PIN: ");
int entry = keyboard.nextInt();
tries++;
while ( entry != pin && tries < max )
{
System.out.println("\nWRONGGGGGG. TRY AGAIN.");
System.out.print("ENTER YOUR PIN: ");
entry = keyboard.nextInt();
tries++;
}
if ( entry == pin )
System.out.println("\nPIN ACCEPTED. YOU'RE IN YOUR ACCOUNT NOW.");
else if ( tries >= max )
System.out.println("\nNO MORE TRIES. ACCOUNT LOCKED.");
}
}
Picture of the output