Assignemnt #60
Code
///Name: Joshua Bautista
///Period: 6
///Project Name: EnterYourPin
///File Name: EnterPin.java
///Date: 1/7/2016
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();
// both makes it so two variables are compared
// a while loop repeats if entry is not the same number as variable
while ( entry != pin )
{
System.out.println("\nINCORRECT PIN. TRY AGAIN.");
System.out.print("ENTER YOUR PIN: ");
// no int because already classified as int in line 12
entry = keyboard.nextInt();
// if you take out entry = keyboard.nextInt, the program will just keep running like a glitch
}
System.out.println("\nPIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.");
}
}
Picture of the output