Advertisement
Spocoman

04. Password Guess

Aug 25th, 2024
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PasswordGuess {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String pass = scanner.nextLine();
  7.  
  8.         if (pass.equals("s3cr3t!P@ssw0rd")) {
  9.             System.out.println("Welcome");
  10.         } else {
  11.             System.out.println("Wrong password!");
  12.         }
  13.     }
  14. }
  15.  
  16. ИЛИ:
  17.  
  18. import java.util.Scanner;
  19.  
  20. public class PasswordGuess {
  21.     public static void main(String[] args) {
  22.         Scanner scanner = new Scanner(System.in);
  23.         String pass = scanner.nextLine();
  24.        
  25.         System.out.println(pass.equals("s3cr3t!P@ssw0rd") ? "Welcome": "Wrong password!");
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement