Assignment #60

Code

    /// Gian Adoremos
    /// Period: 7
    /// Program Name: FiftyNinth Program
    /// File Name: EnterYourPIN.java
    /// Date Finished: 11/19/2015
   
   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 KABIR.");
            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 loops only run continously when the incorrect input is entered
    //while loops continue to run until correct input is entered
    //entry is already am int variable outside of the while loop
    //while loop continues to run nonstop
 

Picture of the output

Assignment 60