Assignemnt #60 and Enter Your PIN
Code
///Name: Luke Shin
///Period: 7
///Project Name: pin
///File Name: pin.java
///Date: 11/20/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 has a boolean statement like if
//Unlike if, WHILE performs the command infinitely, until the boolean
//inside parentheses becomes true.
// int entry was already created
// it will loop the command infinitely because "entry = keyboard.nextInt();" makes program to be able to compare the value
Picture of the output