andreaholeon

Untitled

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