Advertisement
Guest User

Untitled

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