Assignment #60

Code

    /// Name: Jonathan Stine
    /// Period: 5
    /// Program Name: Enter Your PIN
    /// File Name: EnterPIN.java
    /// Date Finished: 1/19/16
    
    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. Here comes the $$$$.");
        
        }
    }
        
    /// 1. A While loop is like an if statement because it's like if ( entry != pin ) entry doesn't equal pin then run the while loop until it does. 
        
    /// 2. It's different from an if statement because it can run more than once.    
    /// 3. Entry is defined as an integer on line 17 so putting int on line 23 is extra work.
    /// 4. The while loop continues to run because entry stays defined as it was originally.    
    
    
 
    

Code Output