Console.WriteLine("Enter your first name:");
string firstName = Console.ReadLine();
Console.WriteLine("Enter your last name:");
string lastName = Console.ReadLine();
Console.WriteLine("Enter your date of birth (YYYY-MM-DD):");
string dobInput = Console.ReadLine();
if (!DateTime.TryParse(dobInput, out dob))
Console.WriteLine("Invalid date format. Please enter the date in the correct format.");
if (CalculateAge(dob) < 18)
Console.WriteLine("You must be at least 18 years old to register.");
string userId = GenerateUserId(firstName, lastName, dob.Year);
string tempPassword = GeneratePassword();
Console.WriteLine("\n--- Customer Information ---");
Console.WriteLine("Full Name: " + firstName + " " + lastName);
Console.WriteLine("User ID: " + userId);
Console.WriteLine("Temporary Password: " + tempPassword);
static int CalculateAge(DateTime dob)
DateTime today = DateTime.Today;
int age = today.Year - dob.Year;
if (dob.Date > today.AddYears(-age)) age--;
static string GenerateUserId(string firstName, string lastName, int yearOfBirth)
string firstPart = firstName.Length >= 3 ? firstName.Substring(0, 3) : firstName + "xxx";
string lastPart = lastName.Length >= 3 ? lastName.Substring(0, 3) : lastName + "xxx";
string userId = firstPart.ToLower() + lastPart.ToLower() + yearOfBirth;
static string GeneratePassword()
Random rand = new Random();
char[] password = new char[8];
password[0] = (char)rand.Next(65, 91);
password[1] = (char)rand.Next(97, 123);
password[2] = (char)rand.Next(48, 58);
for (int i = 3; i < password.Length; i++)
int choice = rand.Next(3);
password[i] = (char)rand.Next(65, 91);
password[i] = (char)rand.Next(97, 123);
password[i] = (char)rand.Next(48, 58);
return new string(password);
static void Shuffle(char[] array, Random rand)
for (int i = array.Length - 1; i > 0; i--)
int j = rand.Next(i + 1);