Assignment #60

Code

    ///Name: Cody Swain
    ///Period: 6
    ///Project Name: EnterPIN
    ///File Name: EnterPIN.java
    ///Date: 12/1/15
    
    import java.util.Scanner;

    public class EnterPIN
    {
    	public static void main( String[] args )
    	{
    		Scanner keyboard = new Scanner(System.in);
    		int pin = 1234;
    
    		System.out.println("WELCOME TO THE BANK OF CODY.");
    		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.");
    	}
    }
    
    
    /* 
    1. Both if and while statements execute code if their conditions are met. 
    2. A while loop will repeat until the conditions are met, while an if statement only checks once.
    3. Entry was already defined as an integer in the previous line. Doesn't need to be redfined.
    4. If that line is deleted, it won't give you the opportunity to re-enter the code. It will continuously loop saying that        you have an incorrect pin and need to enter your pin. 
    5. DONE
    */
    

        
    

Picture of the output

Assignment 60