Assignment #60 and EnterYourPIN

Code

      /// Name: Jason Kim
      /// Period: 7
      /// Program Name: EnterYourPIN
      /// File Name: EnterYourPin.java
      /// Date Finished:10/30/15
      
      import java.util.Scanner;
      
      public class EnterYourPIN
      {
          public static void main (String [] args)
          {
              Scanner keyboard = new Scanner(System.in);
              int pin = 12345;
              
              System.out.println("WELCOME TO THE BANK OF JASON.");
              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.");
          }
      }
      
      //While loop is similar to an if statement in that it has a condition that has to be satisfied.
      //While loop is different from an if statement in that while the condition is satisfied it does the action again and again.
      //You don't need an int inside the while loop because "entry" is already stored as int before the while loop.
      //It prints out the lines without stopping because if the entry is not redefined, entry is still not equal to the pin.

    

Picture of the output

Assignment60