desislava_topuzakova

02. Password

May 8th, 2021
786
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 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.         //име и парола
  7.         String name = scanner.nextLine();
  8.         String password = scanner.nextLine();
  9.  
  10.         //начална стъпка: въвеждане на парола
  11.         //спираме въвеждането: въведената парола == password
  12.         //продължаваме: въведената парола != password
  13.         //повтаряме: въвеждане на парола
  14.         String enteredPassword = scanner.nextLine();
  15.         while(!enteredPassword.equals(password)) {
  16.             enteredPassword = scanner.nextLine();
  17.         }
  18.         System.out.println("Welcome " + name + "!");
  19.  
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment