Assignemnt #60 and Enter PIN
Code
/// Name: Raff Lisbona
/// Period: 6
/// Program Name: Enter PIN
/// File Name: EnterPIN.java
/// Date Finished: 11/19/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 RAFF.");
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();
}
//1. They are both only applied under a certain condition.
//2. A while loop repeats the same thing over and over untill it's right.
// An if statement enters it once in that condition.
//3. The variable "entry" has already been initialized.
//4. It repeats the while loop an infinate amount of times because there
// is nothing to stop it from repeating.
System.out.println("\nPIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.");
}
}
Picture of the output