Advertisement
sergezhu

Untitled

Apr 23rd, 2023
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. namespace ConsoleApp1;
  2.  
  3. using System.Text;
  4.  
  5. public class Task15
  6. {
  7.     public void Run()
  8.     {
  9.         Console.InputEncoding = Encoding.Unicode;
  10.         Console.OutputEncoding = Encoding.Unicode;
  11.  
  12.         string password = "Qwerty123";
  13.         string secretPhrase = "My cat name is Koshka";
  14.         int attempts = 3;
  15.         bool isPasswordCorrect = false;
  16.  
  17.         while ( attempts > 0 && isPasswordCorrect == false )
  18.         {
  19.             attempts--;
  20.            
  21.             Console.WriteLine("Input password:");
  22.             string inputPassword = Console.ReadLine();
  23.  
  24.             isPasswordCorrect = string.Equals( password, inputPassword );
  25.            
  26.             if(isPasswordCorrect)
  27.                 Console.WriteLine($"Password is correct, your secret : {secretPhrase}");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement