Assignemnt #60 Enter Your Pin
Code
Name: Iaroslav Titov
Period: 7
Project Name: PIN
File Name: PIN.java
Date: 11/10/2015
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 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.");
}
}
//WHILE, like IF, has a boolean statement inside parentheses and
//also performs the command coming after it.
//Unlike if, WHILE performs the command infinitely, until the boolean
//inside parentheses becomes true.
//int entry was already created on hte previous line to the WHILE loop.
//if you delete nextInt() command inside the WHILE loop, it will infinitely
//print lines until the program crashes.
Picture of the output