Advertisement
Blonk

Untitled

Nov 19th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main
  4. {
  5.     public static void main( String[] args )
  6.     {
  7.         Scanner keyboard = new Scanner(System.in);
  8.         int pin = 12345;
  9.         int tries = 0;
  10.         int maxTries = 4;
  11.  
  12.         System.out.println("WELCOME TO THE BANK OF MITCHELL.");
  13.         System.out.print("ENTER YOUR PIN: ");
  14.         int entry = keyboard.nextInt();
  15.         tries++;
  16.  
  17.         while ( entry != pin && tries < maxTries )
  18.         {
  19.             System.out.println("\nINCORRECT PIN. TRY AGAIN.");
  20.             System.out.print("ENTER YOUR PIN: ");
  21.             entry = keyboard.nextInt();
  22.             tries++;
  23.         }
  24.  
  25.         if ( entry == pin )
  26.             System.out.println("\nPIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.");
  27.         else if ( tries >= maxTries )
  28.             System.out.println("\nYOU HAVE RUN OUT OF TRIES. ACCOUNT LOCKED.");
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement