Question #59371, Programming & Computer Science / C# | completed
Program.cs
static void Main(string[] args)
{
Console.Write("Enter your e-mail IDs at Pace University: ");
string id = "";
try
{
id = Console.ReadLine();
char s = id[0];
if (!Char.IsLetter(id[0]) || !Char.IsLetter(id[1]))
throw new Exception("in the first and last initials");
for (int i = 2; i < 7; i++)
{
if (!char.IsDigit(id[i]))
{
throw new Exception("in digits");
}
}
}
if (Char.ToLower(id[7]) != 'p' && Char.ToLower(id[7]) != 'n')
throw new Exception("in the last letter");
Console.Write("SUCCESS!");
}
catch (Exception e)
{
Console.WriteLine("Error " + e.Message + "!");
}
Console.ReadKey();
}
}http://www.AssignmentExpert.com/
Comments