Program #60

Code

   
    /// Name: Afaf Nabeeha
    /// Period: 7
    /// Program Name: Enter Your PIN
    /// File Name: PIN.java
    /// Date Finished: 12/3/2015 public class PIN

          import java.util.Scanner;
          
          public class PIN
          {
          	public static void main( String[] args )
          	{
          		Scanner keyboard = new Scanner(System.in);
          		int pin = 12345;
          
          		System.out.println("WELCOME TO THE BANK OF AFAF.");
          		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 statements tell the program what to do and when to do so.
          // 2. The if statement only checks one thing, and is executed only once, but the while loop continues checking until it is untrue.
          // 3. Inside the while loop, there is no need for the "Int" because it was already clarified in the beginning of the program.
          // 4. The deletion makes the program go on forever, because it has no terms to negate it.
          
             
    

Picture of the output

Assignment 60