desislava_topuzakova

02. Password

Feb 5th, 2022
3,085
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Password_02 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String username = scanner.nextLine();
  7.         String password = scanner.nextLine();
  8.  
  9.         //повтаряме: въвеждаме парола
  10.         //спираме: въведенета парола == password
  11.         //продължаваме: въведената парола != password
  12.         String enteredPassword = scanner.nextLine();
  13.  
  14.         while (!enteredPassword.equals(password)) {
  15.             enteredPassword = scanner.nextLine();
  16.         }
  17.         //enteredPassword == password
  18.         System.out.println("Welcome " + username + "!");
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment