Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Ex5 {
- public static void main(String[] args) {
- Scanner sacnner = new Scanner(System.in);
- String username = sacnner.nextLine();
- String password = "";
- String passwordTry = "";
- int counter1 = 0;
- for (int counter = username.length() - 1; counter >= 0;counter--){
- password += username.charAt(counter);
- }
- while (!(passwordTry.equals(password)) && counter1 < 4){
- passwordTry = sacnner.nextLine();
- counter1++;
- if (passwordTry.equals(password)){
- System.out.printf("User %s logged in.",username);
- return;
- }
- if (counter1 <= 3) {
- System.out.println("Incorrect password. Try again.");
- }
- }
- System.out.printf("User %s blocked!",username);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement