Assignment #64 PIN Lockout
Code
///Name: Ian Grant
///Period:5
///Project Name: PIN Lockout
///File Name:GoatBankV2.java
///11/12/15
import java.util.Scanner;
public class GoatBankV2
{
public static void main(String[] args)
{
Scanner stuff=new Scanner(System.in);
int pin = 12345;
int tries=0;
int maxtries=4;
System.out.println("Welcome to the Bank of Goat.");
System.out.print("Enter your PIN: ");
int attempt = stuff.nextInt();
tries++;
while (attempt != pin && tries< maxtries)
{
System.out.println("\nINCORRECT PIN! TRY AGAIN.");
System.out.print("ENTER YOUR PIN: ");
attempt = stuff.nextInt();
tries++;
}
if (attempt==pin)
System.out.println("\nPIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR GOAT ACCOUNT.");
else if(tries>=maxtries)
System.out.println("\nYOU HAVE RUN OUT OF ATTEMPTS. YOUR ACCOUNT IS LOCKED AND YOUR MONEY HAS BEEN TRANSFERED TO THE GOAT.");
}
}
Output