Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7. public static void main(String[] args) {
  8. Scanner sc = new Scanner(System.in);
  9.  
  10. String username = sc.nextLine();
  11. StringBuilder password = new StringBuilder();
  12. // append a string into StringBuilder input1
  13. password.append(username);
  14. // reverse StringBuilder input1
  15. password = password.reverse();
  16.  
  17. int counter = 0;
  18. while(counter < 4){
  19. String guess = sc.nextLine();
  20.  
  21. if(guess.equals(password.toString())){
  22. System.out.println("User " + username + " logged in");
  23. }else{
  24. System.out.println("Incorrect password. Try again.");
  25. }
  26. }
  27. if(counter == 4){
  28. System.out.println("User " + username + "blocked");
  29.  
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement