Assignemnt #65
Code
/// Name: Connor Siri
/// Period: 7
/// Program Name: PIN
/// File Name: PIN.java
/// Date Finished: 11/03/2015
import java.util.Random;
import java.util.Scanner;
public class PIN
{
public static void main( String[] args )
{
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
int pin = 12345;
int tries = 0;
int jee = 4;
System.out.println("Welcome to the bank of Siri");
System.out.print("Enter Pin: ");
int entry = keyboard.nextInt();
tries++;
while ( entry != pin && tries < jee )
{
System.out.println("\n Incorrect pin. try again");
System.out.print("Enter pin: ");
entry = keyboard.nextInt();
tries++;
}
if ( entry == pin )
System.out.println("\nPin accepted. Welcome to account");
else if (tries >= 3 )
System.out.println("\nYou are out of tries. Come back NEVER");
}
}
Picture of the output