desislava_topuzakova

02. Password

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