Assignemnt #56 ENTER YOUR PIN

Code


///Name: JJ Deng
///Period: 6
///Program Name: Enter Your PIN
///File Name: Pin.java
///Date Finished: 12/3/15    

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 JJ.");
		System.out.print("ENTER YOUR PIN: ");
		int entry = keyboard.nextInt();

		while ( entry != pin )  ///the while loop have the same command format as if statements
                                ///but if statements dont use ! as a command
                                ///if u take out entry = keyboard then the program might just explode
                                ///the int has already been said up there so the system will know
		{
			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.");
	}
}

     

Picture of the output

Assignment 43