Advertisement
Guest User

Untitled

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