-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateAccountFunction.cpp
More file actions
40 lines (35 loc) · 1.3 KB
/
CreateAccountFunction.cpp
File metadata and controls
40 lines (35 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
void createAccount() {
if (accountCount >= MAX_ACCOUNTS) {
cout << "Account limit reached. Cannot create more accounts.\n";
return;
}
Account newAccount;
newAccount.accountNumber = nextAccountNumber++;
cout << "Enter the account holder's name: ";
cin.ignore();
getline(cin, newAccount.name);
while (!isValidName(newAccount.name)) {
cout << "Invalid name. Please enter a valid name:\n";
getline(cin, newAccount.name);
}
bool validMobile = false;
while (!validMobile) {
cout << "Enter mobile number (11 digits, starts with 03): ";
cin >> newAccount.mobileNumber;
if (!isValidMobileNumber(newAccount.mobileNumber)) {
cout << "Invalid mobile number. Try again.\n";
} else {
validMobile = true;
}
}
cout << "Enter initial deposit amount (minimum 500): ";
cin >> newAccount.balance;
while (cin.fail() || newAccount.balance < 500) {
cin.clear();
cin.ignore(1000, '\n');
cout << "Invalid amount. Please enter 500 or more:\n";
cin >> newAccount.balance;
}
accounts[accountCount++] = newAccount;
cout << "Account created successfully! Account Number: " << newAccount.accountNumber << "\n";
}