Assignemnt #60

Code

///colin hinton
///5th period
///Pin
///Pin.java
///11/2/2015

import java.util.Scanner;

class Pin
{
    public static void main (String [] args)
    {
        Scanner keyboard = new Scanner (System.in);
        int pin = 12345;
        
        System.out.println("WECLOME TO YOUR BANK.");
        System.out.print("enter your pin pls ");
        int entry = keyboard.nextInt();
        
        
        while (entry != pin)
        {
            System.out.println(" WRONG PIN, TRY AGAIN ");
            System.out.print(" enter your pin ");
            entry = keyboard.nextInt();
        }
        
        System.out.println(" PIN accepted, you have the power.");
    }
}
    // While is similar to if statements because it creats direct questions that the code has to answer, however what makes it different than an if statement is that while statements loop when they are suscessful, or in this case not correct.

    // There is no int in front of the entry = keyboard.nextInt(), because it is implied that the statement is an integer because of how the program works. 

    // By removing the entry = keyboard it looped the text infinetly because that is what the command was. 

    

Picture of the output

Assignment 1