Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Login {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String userName = scanner.nextLine();
- String userPassword = scanner.nextLine();
- String backwards = new StringBuilder(userName).reverse().toString();
- int counter = 0;
- while (!userPassword.equals(backwards)) {
- System.out.println("Incorrect password. Try again.");
- userPassword = scanner.nextLine();
- counter++;
- if (counter >= 3) {
- System.out.printf("User %s blocked!", userName);
- break;
- }
- }
- if(userPassword.equals(backwards)){
- System.out.printf("User %s logged in.", userName);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement