Assignemnt #60

Code


 /// Name: Daniel Nguyen
 /// Period: 6
 /// Program Name: Monte Program
 /// File Name: Monte.java
 /// Date Finished: 9/9/2015
 
// a while loop is similar to an if statement because it tests if a statement is true and runs code after that depending on it
// A while loop is different from an if statement because it continues to run the code until the statement is no longer true
// There is no int because "entry" as a variable is already defined as an int in the previous code
// When line 29 is removed it causes the while loop to never be satisfied and keeps running until it is which is never
 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: ");
			entry = keyboard.nextInt();
		}

		System.out.println("\nPIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.");
	}
}

    


    

Picture of the output

Assignment 3
BACK HOME NEXT