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 password = scanner.nextLine();
- int count = 0;
- String result = "";
- while (true) {
- int pass = password.length();
- for (int i = pass - 1; i >= 0; i--) {
- result += password.charAt(i);
- }
- if (!(username.equals(result))) {
- count ++;
- }
- if (count== 4) {
- System.out.printf("User %s blocked!", username);
- }
- if (username.equals(result)) {
- System.out.printf("User %s logged in.", username);
- } else if (count< 4){
- System.out.println("Incorrect password. Try again.");
- }
- password = scanner.nextLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement