Assignment #60 Enter Your PIN

Code

    /// Name: John Huh
    /// Period: 6
    /// Program Name: Enter Your PIN
    /// File Name: EnterPIN.java
    /// Date Finished: 12/2/2015
    
    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 JOHN.");
    		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();
    		}
    
            // A while statements is different from an if statement because if the user gives an invalid number, it will contine to loop the text.  They are the same because if both statements are given a correct answer, they will both move on.
            // If the entry statement is taken out of the while loop, it will continue to loop itself without stopping
            
    		System.out.println("\nPIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.");
    	}
    }
    

Picture of the output

Assignment 1