Advertisement
lol1234561

Untitled

Mar 8th, 2023 (edited)
1,006
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. public class Main {
  3.     public static void main(String[] args) {
  4.         Scanner keyboard = new Scanner(System.in);
  5. int PIN = 12345;
  6. int tries = 0;
  7.         System.out.println("Welcome to the bank!");
  8.         System.out.println("Please enter your pin: ");
  9.         int entry = keyboard.nextInt();
  10.        tries++;
  11.         while(entry != PIN && tries < 3){
  12.             System.out.println("Incorrect pin. Try again");
  13.             System.out.println("Enter your pin: ");
  14.             entry = keyboard.nextInt();
  15.             tries++;
  16.  
  17.         }
  18.  
  19.  
  20.         if(entry == PIN){
  21.             System.out.println("Pin accepted. You now have access to your account.");
  22.         } else if (tries >= 3) {
  23.             System.out.println("You have been locked out of your account, please try again later.");
  24.         }
  25.  
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement