John_IV

Untitled

Sep 25th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. package com.company;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6. public static void main(String[] args) {
  7.  
  8. Scanner scanner = new Scanner(System.in);
  9. String username;
  10. username=scanner.nextLine();
  11. String password;
  12. for(int i=username.length()-1; i>=0; i--)
  13. {
  14. password+=username.charAt(i);
  15. }
  16. String pop=scanner.nextLine();
  17.  
  18. int count=0;
  19. boolean isBlocked=false;
  20. while (!password.equals(pop));
  21. {
  22. count++;
  23. if (count==4)
  24. {
  25. System.out.println("User %s blocked!", username);
  26. isBlocked=true;
  27. break;
  28. }
  29. System.out.println("Incorrect password. Try again.");
  30. pop=scanner.nextLine();
  31. }
  32. if (isBlocked)
  33. {
  34. System.out.println("User %s logged in.", username);
  35. }
  36.  
  37.  
  38.  
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment