desislava_topuzakova

02. Password

May 16th, 2020
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class demo {
  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.         //стоп: входна парола == начална парола
  11.         //продължаваме на въвеждаме парола: входна парола != начална парола
  12.  
  13.         String enteredPassword = scanner.nextLine();
  14.         while (!enteredPassword.equals(password)){
  15.             enteredPassword = scanner.nextLine();
  16.         }
  17.         System.out.println("Welcome " + userName + "!");
  18.  
  19.  
  20.     }
  21. }
Add Comment
Please, Sign In to add comment