Advertisement
jhei13

VARCHECK_NEW UPDATE W/ SWICTH 001

Jul 30th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.60 KB | None | 0 0
  1.  
  2.     class Program
  3.     {
  4.  
  5.         static void Main(string[] args)
  6.         {
  7.             Console.Write("Input Variable: ");
  8.              string variable = Console.ReadLine();
  9.              char[] cha = variable.ToCharArray();
  10.              
  11.             int state = 0;
  12.  
  13.             for (int i = 0; i <= cha.Length-1 ; i++)
  14.             {
  15.                 char ch = cha[i];
  16.  
  17.                 switch (state)
  18.                 {
  19.                     case 0:
  20.                         {
  21.                             if (!(ch < 64 || ch > 91) || (ch == 95) || !(ch < 97 || ch > 123))
  22.                             {
  23.  
  24.                                 state = 1;
  25.                                 if (i == cha.Length - 1)
  26.                                     goto case 3;
  27.                             }
  28.                             else
  29.                                 goto default;
  30.                                                        
  31.                             break;
  32.                         }
  33.                     case 1:
  34.                         {
  35.                             if (i == cha.Length - 1)
  36.                             {
  37.                                 goto case 2;
  38.                             }
  39.                             else
  40.                             {
  41.                                 if (!(ch < 48 || ch > 57) || !(ch < 65 || ch > 91) || (ch == 95) || !(ch < 97 || ch > 123))
  42.                                 {
  43.                                    
  44.                                     state = 2;
  45.                                 }
  46.                                 else
  47.                                     goto default;
  48.                             }
  49.                             break;
  50.                         }
  51.                     case 2:
  52.                         {
  53.                             if (!(ch < 48 || ch > 57) || !(ch < 65 || ch > 91) || (ch == 95) || !(ch < 97 || ch > 123))
  54.                             {                          
  55.                                     goto case 3;
  56.                             }
  57.                             else
  58.                                 goto default;
  59.                         }
  60.                     case 3:
  61.                         {
  62.                             Console.WriteLine("success");
  63.                             return;
  64.                         }
  65.                     default:
  66.                         {
  67.                             Console.WriteLine(" Oooppss ...Invalid!!!");
  68.                             return;
  69.                         }
  70.                 }
  71.             }
  72.  
  73.       //coded by elamigo-JGT ACT CS STUDENTS
  74.             }
  75.         }
  76.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement