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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
//Main program
#include <iostream>
#include <iomanip>
#include <string>
#include "bankAccount.h"
using namespace std;
const int MAX_NUM_OF_ACCOUNTS = 10;
void showMainMenu();
void showAccountMenu();
int searchBankAccount(bankAccount list[], int length, int acctNum);
void addBankAccount(bankAccount list[], int& length);
void processBankAccount(bankAccount list[], int length, int acctNum);
void printBankAccountsData(bankAccount list[], int length);
// if you need more functions, add their headers here.
int main()
{
bankAccount bankAccounts[MAX_NUM_OF_ACCOUNTS];
int numOfBankAccounts = 0; // this shows the actual number of bank accounts in the array
&bankAccount::getAccountNumber;
showMainMenu();
int userinput;
int acctNum;
switch (userinput) {
case 1: addBankAccount(bankAccounts, numOfBankAccounts);
break;
case 2: printBankAccountsData(bankAccounts, numOfBankAccounts);
break;
case 3: cout << "Enter account Number: ";
cin >> acctNum;
searchBankAccount(bankAccounts, numOfBankAccounts, acctNum);
if (acctNum > 0) {
showAccountMenu();
switch (userinput) {
case 5: processBankAccount(bankAccounts, numOfBankAccounts, acctNum);
break;
case 6: processBankAccount(bankAccounts, numOfBankAccounts, acctNum);
break;
case 7: processBankAccount(bankAccounts, numOfBankAccounts, acctNum);
break;
case 8: showMainMenu();
system("pause");
}
if (int numofBankAccounts = 0)
{
addBankAccount(bankAccounts, numofBankAccounts);
}
break;
case 4: return 0;
return 0;
}
}
void showMainMenu();
{
cout << "Hello, welcome to my bank! Press the number next to the requested action and press enter to continue" << endl;
cout << "1. Add a bank account." << endl;
cout << "2. Print existing bank accounts." << endl;
cout << "3. Search existing bank accounts based on the account number." << endl;
cout << "4. Exit the program." << endl;
}
void showAccountMenu()
{
cout << "5. Deposit money to the account." << endl;
cout << "6. Withdraw money from the account." << endl;
cout << "7. Check the balance on the account." << endl;
cout << "8. Exit to main menu." << endl;
}
void addBankAccount(bankAccount list[], int& length){
int accountNum;
cout << "Enter the new account number: " << endl;
cin >> accountNum;
bankAccount() { list[getAccountNumber()]; }
string fullName;
cout << "Enter your name: " << endl;
cin >> fullName;
bankAccount() { list[getAccountHolderName()]; }
}
void processBankAccount(bankAccount list[], int length, int acctNum)
{
int userinput;
double deposit, withdrawal, balance;
cout << "1. Add a deposit." << endl;
cout << "2. Do a withdrawal." << endl;
cout << "3. See your remaining balance" << endl;
cin >> userinput;
switch (userinput) {
case 1: {
cout << "How much do you want to deposit?" << endl;
cin >> deposit;
balance = balance + deposit;
}
case 2: {
cout << "How much do you want to withdraw?" << endl;
cin >> withdrawal;
balance = balance - withdrawal;
}
case 3:
cout << "Remaining balance: " << balance << endl;
}
}
int searchBankAccount(bankAccount list[], int length, int acctNum)
{
int userinput;
cout << "Enter the number of the account you would like to find." << endl;
cin >> userinput;
if (userinput = bankAccount.accountNum)
{
printBankAccountsData(list, length);
}
}
void printBankAccountsData(bankAccount list[], int length)
{
string fullName = bankAccount::getAccountHolderName;
int accountNum;
string type;
double balance;
for (int i = 1; i < MAX_NUM_OF_ACCOUNTS; i++)
{
cout << "Details of all accounts:" << endl;
cout << " --- ---- ------- ------- " << endl;
cout << "Account no.: " << << endl;
cout << "Name: " << fullName << endl;
cout << "Current Balance: " << balance << endl;
}
}
|