Advertisement
desislava_topuzakova

02. Password

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