SHARE
TWEET

Untitled

a guest Jan 18th, 2020 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class Login {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         String username = scanner.nextLine();
  8.         String password = scanner.nextLine();
  9.         int count = 0;
  10.         String result = "";
  11.  
  12.         while (true) {
  13.  
  14.             int pass = password.length();
  15.             for (int i = pass - 1; i >= 0; i--) {
  16.                 result += password.charAt(i);
  17.             }
  18.  
  19.             if (!(username.equals(result))) {
  20.                 count ++;
  21.             }
  22.             if (count== 4) {
  23.                 System.out.printf("User %s blocked!", username);
  24.             }
  25.  
  26.             if (username.equals(result)) {
  27.                 System.out.printf("User %s logged in.", username);
  28.             } else  if (count< 4){
  29.                 System.out.println("Incorrect password. Try again.");
  30.             }
  31.             password = scanner.nextLine();
  32.  
  33.         }
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top