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