Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement