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