Assignment 60; EnterPin
Code
// Donovan Rich
// Period 6
// Enter your PIN
// EnterPin.java
// 12/2/2015
import java.util.Scanner;
public class EnterPin
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int pin = 1997, attempts = 4;
System.out.println("WELCOME TO THE NATIONAL BANK BANK OF memes.");
System.out.print("ENTER YOUR PIN: ");
int entry = keyboard.nextInt();
while ( entry != pin )
{
attempts -= 1;
if ( attempts > 0 )
{
System.out.println("\nINCORRECT PIN. TRY AGAIN.");
System.out.print("ENTER YOUR PIN ( " + attempts + " ATTEMPTS REMAINING): ");
entry = keyboard.nextInt();
}
else
{
System.out.println( "\nINCORRECT PIN." );
System.out.println( "YOU HAVE BEEN LOCKED OUT OF YOUR ACCOUNT." );
pin = entry;
}
}
if ( attempts > 0 )
System.out.println("\nPIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.");
}
}
Picture of the output