Assignment #54

Code

  /// Name: Sam Wilson
  /// Period: 6
  /// Program Name: enterpin
  /// File Name: enterpin.java
  /// Date Finished: 12/1/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 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: "); //Name: Mark Katz
        
    			entry = keyboard.nextInt();
    		}
    
    		System.out.println("\nPIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.");
    	}
    }
    
    // a while loop is similar to an 'if' statement because a certain criteria has to be met in order for a statement to be shown
    //a while loop is different because it can be used over and over again
    //because an integer has already been declared, so an int entry is a different integer
    //if you take it out any other number besides 12345, will end the program
    

Picture of the output

Assignment 31