desislava_topuzakova

2. Парола

Dec 5th, 2021
610
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package WhileLoop;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Password_02 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String username = scanner.nextLine();
  9.         String password = scanner.nextLine();
  10.  
  11.         //повтаряме: въвеждаме нова парола
  12.         //спираме: въведената парола == password
  13.         //продължаваме: въведената парола != password
  14.         String enteredPassword = scanner.nextLine();
  15.         while (!enteredPassword.equals(password)) {
  16.             enteredPassword = scanner.nextLine();
  17.         }
  18.         //enteredPassword == password
  19.         System.out.printf("Welcome %s!", username);
  20.     }
  21. }
  22.  
RAW Paste Data