TheBulgarianWolf

Username check

Apr 10th, 2020
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class SoftUni {
  5.    
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.         System.out.print("Enter your username: ");
  9.         String username = sc.nextLine();
  10.         String check = "";
  11.         String reversed = "";
  12.         char[] try1 = username.toCharArray();
  13.  
  14.         for (int i = try1.length-1; i>=0; i--) {
  15.             reversed += try1[i];
  16.         }
  17.         while(true){
  18.             System.out.print("Enter your reversed username to comfirm: ");
  19.             check = sc.nextLine();
  20.             if(check.equals(reversed)){
  21.                 break;
  22.             }
  23.         }
  24.        
  25.         System.out.println("User " + username + " logged in.");
  26.        
  27.     }
  28.  
  29. }
Add Comment
Please, Sign In to add comment