Assignemnt #60 and Enter PIN
Code
///Name: Dakota Donahue
///Period: 5
///Project Name: Enter PIN
///File Name:EnterPIN.java
///Date: 12/4/2015
//1. A while loop is like an if statement because it sets up a certain parameter which, if met, carries out a specific task.
//2. A while loop is continually repeated until its conditions are not met unalike an if statemnt which is only carried out once.
//3. It doesn't have to be remembered.
//4. The while loop loops back and repeates itself when entry = Keyboard.nextInt is removed.
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.");
}
}