Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Input Variable: ");
- string variable = Console.ReadLine();
- char[] cha = variable.ToCharArray();
- int state = 0;
- for (int i = 0; i <= cha.Length-1 ; i++)
- {
- char ch = cha[i];
- switch (state)
- {
- case 0:
- {
- if (!(ch < 64 || ch > 91) || (ch == 95) || !(ch < 97 || ch > 123))
- {
- state = 1;
- if (i == cha.Length - 1)
- goto case 3;
- }
- else
- goto default;
- break;
- }
- case 1:
- {
- if (i == cha.Length - 1)
- {
- goto case 2;
- }
- else
- {
- if (!(ch < 48 || ch > 57) || !(ch < 65 || ch > 91) || (ch == 95) || !(ch < 97 || ch > 123))
- {
- state = 2;
- }
- else
- goto default;
- }
- break;
- }
- case 2:
- {
- if (!(ch < 48 || ch > 57) || !(ch < 65 || ch > 91) || (ch == 95) || !(ch < 97 || ch > 123))
- {
- goto case 3;
- }
- else
- goto default;
- }
- case 3:
- {
- Console.WriteLine("success");
- return;
- }
- default:
- {
- Console.WriteLine(" Oooppss ...Invalid!!!");
- return;
- }
- }
- }
- //coded by elamigo-JGT ACT CS STUDENTS
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement