Assignment #60 Enter Your PIN

Code

    /// Name: Matthew Lorence
    /// Period: 5
    /// Program Name: EnterPIN
    /// File Name: EnterPIN.java
    
    /// A while loop only ones under specific conditions like an ifstatment.
    /// A while loop will go on infinitely unlike an if statement which only runs once.
    /// The int is already define above the while loop.
    /// The while loop goes on infinitely without letting you put in a new pin.  
    /// It does this because it keeps running until you put in the wrong code, but if you can't put in the right code it runs infinitely.
    import java.util.Scanner;
    
    public class EnterPIN
    {
    	public static void main( String[] args )
    	{
    		Scanner keyboard = new Scanner(System.in);
    		int pin = 12345;
    
    		System.out.println("WELCOME TO THE BANK OF JOSHUA.");
    		System.out.print("ENTER YOUR PIN: ");
    		int entry = keyboard.nextInt();
    
    		while ( entry != pin )
    		{
    			System.out.println("\nINCORRECT PIN. TRY AGAIN.");
    			System.out.print("ENTER YOUR PIN: ");
    			entry = keyboard.nextInt();
    		}
    
    		System.out.println("\nPIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.");
    	}
    }
        
        
    

Picture of the output

Assignment 60