Advertisement
Guest User

PassCode

a guest
Mar 6th, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.36 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         int PassCode = 7898;
  8.         Console.Write("Enter the PassCode: ");
  9.         string input = Console.ReadLine();
  10.         int output;
  11.         bool Validation = int.TryParse(input, out output);
  12.         bool check = PassCode == output;
  13.         while (!check)
  14.         {
  15.             if(check)
  16.             {
  17.                 Console.WriteLine("Correct PassCode");
  18.             }
  19.             else if (!check)
  20.             {
  21.                 for (int i = 0; i < 2; i++)
  22.                 {
  23.                     if (check == false)
  24.                     {
  25.                         Console.WriteLine("Wrong PassCode");
  26.                         Console.Write("Enter the PassCode: ");
  27.                         input = Console.ReadLine();
  28.                         Validation = int.TryParse(input, out output);
  29.                         check = PassCode == output;
  30.                     }
  31.                     else if(check==true)
  32.                     {
  33.                         continue;
  34.                     }
  35.                 }
  36.                 if (check == false)
  37.                 {
  38.                     Console.WriteLine("Program Blocked!");
  39.                     break;
  40.                 }
  41.             }
  42.         }
  43.         if(check == true)
  44.         {
  45.             Console.WriteLine("Correct PassCode");
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement