Assignemnt #60 Enter Your Pin
Code
///Name: Joshua Pell
///Period: 6
///Project Name: Enter Your Pin
///File Name: EnterPIN.java
///Date: 12/4/2015
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();
//If the While is true it will be read just like an if statement
//it will stop when the while statment isn't true
// entry was all ready initialized
//It will never not be true
while ( entry != pin )
{
System.out.println("\nINCORRECT PIN. TRY AGAIN.");
System.out.print("ENTER YOUR PIN: ");
entry = keyboard.nextInt();
}
System.out.println("PIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.");
}
}
Picture of the output