Advertisement
Guest User

Untitled

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