Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Problem12 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String username = scanner.nextLine();
- String reverse = "";
- String password = scanner.nextLine();
- boolean isValid = password.equals("reverse");
- int count = 0;
- for (int i = username.length() - 1; i >= 0; i--) {
- reverse = reverse + username.charAt(i);
- }
- while (!isValid) {
- System.out.println("Incorrect password. Try again.");
- String newPassword = scanner.nextLine();
- password = newPassword;
- count++;
- if (count > 2) {
- System.out.printf("User %s blocked!", username);
- break;
- }
- }
- while (isValid) {
- System.out.printf("User %s logged in.", username);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement