Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package BasicSyntax;
- 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 = "";
- for (int i = username.length() - 1; i >= 0; i--) {
- password += username.charAt(i);
- }
- String inputPassword = scanner.nextLine();
- int count = 1;
- while (!inputPassword.equals(password)) {
- count++;
- System.out.println("Incorrect password. Try again.");
- inputPassword = scanner.nextLine();
- if (count == 4) {
- break;
- }
- }
- if (inputPassword.equals(password)) {
- System.out.println("User " + username + " logged in.");
- } else {
- System.out.println("User " + username + " blocked!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement