Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- String userName = null;
- String password = null;
- String userNamePassword = "";
- int counter = 0;
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- userName = scanner.nextLine();
- char userNameReverse[] = userName.toCharArray();
- for (int i = userName.length() - 1; i >= 0; i--) {
- userNamePassword += userNameReverse[i];
- }
- while(counter < 4) {
- password = scanner.nextLine();
- if (!userNamePassword.equals(password)) {
- counter++;
- if (counter == 4) {
- System.out.printf("User %s blocked!", userName);
- } else {
- System.out.println("Incorrect password. Try again.");
- }
- } else {
- System.out.printf("Username %s logged in.",userName);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement