filipparodriguezz

Untitled

Nov 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 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.  
  11.                 System.out.println("WELCOME TO THE BANK OF MITCHELL.");
  12.                 System.out.print("ENTER YOUR PIN: ");
  13.                 int entry = keyboard.nextInt();
  14.                 tries++;
  15.  
  16.                 while ( entry != pin && tries < 4 )
  17.                 {
  18.                     System.out.println("\nINCORRECT PIN. TRY AGAIN.");
  19.                     System.out.print("ENTER YOUR PIN: ");
  20.                     entry = keyboard.nextInt();
  21.                     tries++;
  22.                 }
  23.  
  24.                 if ( entry == pin )
  25.                     System.out.println("\nPIN ACCEPTED. YOU NOW HAVE ACCESS TO YOUR ACCOUNT.");
  26.                 else if ( tries >= 4 )
  27.                     System.out.println("\nYOU HAVE RUN OUT OF TRIES. ACCOUNT LOCKED.");
  28.             }
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment