Advertisement
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 sc = new Scanner(System.in);
- String username = sc.nextLine();
- StringBuilder password = new StringBuilder();
- // append a string into StringBuilder input1
- password.append(username);
- // reverse StringBuilder input1
- password = password.reverse();
- int counter = 0;
- while(counter < 4){
- String guess = sc.nextLine();
- if(guess.equals(password.toString())){
- System.out.println("User " + username + " logged in");
- }else{
- System.out.println("Incorrect password. Try again.");
- }
- }
- if(counter == 4){
- System.out.println("User " + username + "blocked");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement