Advertisement
veronikaaa86

02. Password

Jun 10th, 2023
963
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. package whileLoop;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P02Password {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String username = scanner.nextLine();
  10.         String regPass = scanner.nextLine();
  11.  
  12. //        while (true) {
  13. //            String currentPass = scanner.nextLine();
  14. //
  15. //            if (currentPass.equals(regPass)) {
  16. //                break;
  17. //            }
  18. //        }
  19.  
  20.         String currentPass = scanner.nextLine();
  21.         while (!currentPass.equals(regPass)) {
  22.             currentPass = scanner.nextLine();
  23.         }
  24.  
  25.         System.out.printf("Welcome %s!", username);
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement