A to 65
start:
Console.Write("Enter apha or their asciis : ");
string input = Console.ReadLine();
char inputChar = ' ';
if (input.Length > 0)
inputChar = input[0];
int switchCase = 3;
if (input.Length < 1 || input.Length > 3 || input == "000")
{
switchCase = 3;
}
else if ((inputChar >= 'a' && inputChar <= 'z' || inputChar >= 'A' && inputChar <= 'Z') && input.Length == 1)
switchCase = 1;
else if (inputChar >= '0' && inputChar <= '9' && input.Length >= 2 && input.Length <= 3)
{
if (input[1] >= '0' && input[1] <= '9')
{
if (input.Length == 2)
{
if (int.Parse(input) >= 65 && int.Parse(input) <= 90 || int.Parse(input) >= 97 && int.Parse(input) <= 99)
{
if (int.Parse(input) >= 97 && int.Parse(input) <= 122 || int.Parse(input) >= 65 && int.Parse(input) <= 90)
switchCase = 2;
}
}
else
{
if (input[2] >= '0' && input[2] <= '9')
if (int.Parse(input) >= 100 && int.Parse(input) <= 122)
{
switchCase = 2;
}
}
}
}
switch (switchCase)
{
case 1:
Console.WriteLine("Alpha : " + input);
Console.WriteLine("Ascii : " + (int)inputChar);
break;
case 2:
Console.WriteLine("Ascii : " + input);
Console.WriteLine("Alpha : " + (char)int.Parse(input));
break;
default:
Console.WriteLine("Invalid Input : " + input);
break;
}
Console.WriteLine();
goto start;
Comments
Post a Comment