Assignemnt 60 and Enter Your Pin
Code
/// Name: Xinting Chen
/// Period: 7
/// Program Name: EnterYourPin
/// File Name: EnterYourPin.java
/// Date Finished: 12/3/2015
import java.util.Scanner;
public class EnterYourPin
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int pin = 12345;
System.out.println("WELCOME TO THE BANK OF Xinting.");
System.out.print("ENTER YOUR PIN: ");
int entry = keyboard.nextInt();
while ( entry != pin )
///"while" loop have the same command format as "if" statements
///"if" statements don't use ! as a symbol
///"int" has already initially mentioned on the top
///If you take out "entry = keyboard" then the program will not work
{
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.");
}
}
Picture of the output