desislava_topuzakova

5. Познай Паролата

Oct 24th, 2021
668
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. package CodnitionalStatements;
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class PasswordGuess_05 {
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.         String password = scanner.nextLine();
  10.  
  11.         //проверка дали съвпада с "s3cr3t!P@ssw0rd" -> печатаме "Welcome"
  12.         //ако не съвпада -> печатаме "Wrong password!"
  13.  
  14.         if (password.equals("s3cr3t!P@ssw0rd")) { //съвпадат
  15.             System.out.println("Welcome");
  16.         } else {  // не съвпадат
  17.             System.out.println("Wrong password!");
  18.         }
  19.     }
  20. }
  21.  
RAW Paste Data