Assignemnt #60 Enter Your Pin

Code

   
    /// Name: Jake Johnson
    /// Period: 7
    /// Program Name: EnterYourPin
    /// File Name: EnterYourPin.java
    /// Date Finished: 12/4/2015
    
import java.util.Scanner;

public class EnterYourPin
{
    public static void main(String[] args)
    {
        Scanner keyboard = new Scanner(System.in);
        int pin = 12345;
        
        System.out.println("WELCOME TO THE BANK OF JAKE");
        System.out.print("ENTER YOUR PIN: ");
        int entry = keyboard.nextInt();
        
        while (entry!= pin) //a while loop is similar to an if statement because it runs code when certain conditions are met, it is different because it runs that code until the condition is met whereas in an if statement it runs it once
        {
            System.out.println("\nINCORRECT PIN. TRY AGAIN");
            System.out.print("ENTER YOUR PIN: ");
            entry = keyboard.nextInt(); //we do not need to write int here because entry is already an established variable. deleting this line will make it so that the program will infinitely print the code in the loop because entry will always != pin if it never gets reassigned to a different value
        }
        
        System.out.println("\n PIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT");
    }
}

    

Picture of the output

This should work