Advertisement
Guest User

Untitled

a guest
Sep 27th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class TEST {
  3.     public static void main(String[] args) {
  4.         Scanner scan=new Scanner(System.in);
  5.         String user = scan.nextLine();
  6.         String pass = new StringBuilder(user).reverse().toString();
  7.  
  8.         for (int i = 1; i <=4 ; i++) {
  9.             String login = scan.nextLine();
  10.             if (login.equals(pass) ) {
  11.                 System.out.printf("User %s logged in.", user);
  12.                 break;
  13.             }
  14.  
  15.             else if(i==4) {
  16.                 System.out.printf("User %s blocked!", user);
  17.             }
  18.             else {
  19.                 System.out.println("Incorrect password. Try again.");
  20.             }
  21.  
  22.  
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement