Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- int PIN = 12345;
- int tries = 0;
- System.out.println("Welcome to the bank!");
- System.out.println("Please enter your pin: ");
- int entry = keyboard.nextInt();
- tries++;
- while(entry != PIN && tries < 3){
- System.out.println("Incorrect pin. Try again");
- System.out.println("Enter your pin: ");
- entry = keyboard.nextInt();
- tries++;
- }
- if(entry == PIN){
- System.out.println("Pin accepted. You now have access to your account.");
- } else if (tries >= 3) {
- System.out.println("You have been locked out of your account, please try again later.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement