Order Now  +1 678 648 4277 

Bank Management Assignment Solution Using C++


Question:

A bank manages the data of its customers (customer number, address, date of birth, telephone number), as well as their accounts (account number, account type, account balance). Possible account types are current account and savings account. Write a program in C++ that offers the possibility to re-enter customers, create or delete accounts and carry out transactions such as transfers, deposits, and withdrawals on the various accounts.

Solutions:

#include #include using namespace std; // Structure lists struct accountInfo { string name; string tell; //Japanese for phone string accounttype; int accountnumber; string birth; string address; bool deleted; int balance; }; //Function prototypes void getAccount(accountInfo *); void printAccount(accountInfo *); void editAccount(accountInfo *); void delaccount(accountInfo *); void withdrawalsTrans(accountInfo *p); void depositTrans(accountInfo *p); void transferTrans(accountInfo *p); int accountSize = 1; int main() { int NUM_SPEAKERS = 10; //The number of accounts int index; //Loop counter... accountInfo infos[10]; //Array to hold the stats for each account... //Choice for menu int submenu; const int enter = 1, change = 2, print = 3, del = 4, withdrow = 5, deposit = 6, transfer = 7, leave = 10; //Menu display with a do-while loop do { cout << "Please select a choice from this submenu.\n" << "1) Enter account Information.\n" << "2) Change account Information.\n" << "3) Print account Information.\n" << "4) Delete account Information.\n" << "5) Withdrow Transaction.\n" << "6) deposits Transaction.\n" << "7) transfer Transaction.\n" << "10) Leave this menu.\n" << "Selection: "; cin >> submenu; switch (submenu) { case enter: { //enter account information getAccount(infos); } break; case change: { //change account information editAccount(infos); } break; case del: { //change account information delaccount(infos); } break; case withdrow: { //change account information withdrawalsTrans(infos); } break; case deposit: { //change account information depositTrans(infos); } break; case transfer: { //change account information transferTrans(infos); } break; case print: { //print account information printAccount(infos); } break; } } while (submenu != leave); system("pause"); return 0; } void getAccount(accountInfo *p) { //where p stands for the array name //array name = pointer int index = 0; cout << "\n Number of accouunts:"; cin >> accountSize; // int size = 10; // Array size for (index = 0; index < accountSize; index++) { cout << "Please enter the following information of account id " << index << " : \n"; cout << "account Name:"; cin.ignore(); //To skip remaining '\n' character getline(cin, p[index].name); cout << "\naccount Telephone Number:"; // cin.ignore(); //To skip remaining '\n' character getline(cin, p[index].tell); cout << "\nbirth:"; getline(cin, p[index].birth); cout << "\naccount Type:"; getline(cin, p[index].accounttype); p[index].accountnumber = index; // cin.ignore(); //To skip remaining '\n' character cout << "\nAccount Address:"; getline(cin, p[index].address); cout << "\nBalance:"; cin >> p[index].balance; } } void printAccount(accountInfo *p) { int index = 0; //int size = 10; // Array size for (index = 0; index < accountSize; index++) { if (!p[index].deleted) { cout << "The information entered for each account is: \n"; cout << "Account id " << index << endl; cout << "Name: " << p[index].name << endl; cout << "Telephone Number: " << p[index].tell << endl; cout << "Account Number: " << p[index].accountnumber << endl; cout << "Account Type: " << p[index].accounttype << endl; cout << "Address: " << p[index].address << endl; cout << "Birth: " << p[index].birth << endl; cout << "Account Balance: " << p[index].balance << endl; } } } void editAccount(accountInfo *p) { int i; //placeholder for the number wanted to be edited. cout << "Please enter the the account id you would like to edit." << "\nExample: 5\n"; cin >> i; if (i <= accountSize) { cout << endl; cout << "Please enter the updated information of the account: \n"; cout << "Account Name:"; cin.ignore(); //To skip remaining '\n' character getline(cin, p[i].name); cout << "\nAccount Telephone Number:"; getline(cin, p[i].tell); cout << "\nAccount Type:"; getline(cin, p[i].accounttype); cout << "\nAccount address:"; getline(cin, p[i].address); cout << "\nbirth:"; getline(cin, p[i].birth); cout << "\nBalance:"; cin >> p[i].balance; } else { cout << "I'm sorry, that is an invalid selection.\n" << "The accounts range from 0-9.\n" << "Please select this option again.\n\n"; } } void delaccount(accountInfo *p) { int i; //placeholder for the number wanted to be edited. cout << "Please enter the number of the account id you would like to edit." << "\nExample: 5\n"; cin >> i; if (i <= accountSize) { p[i].deleted = true; cout << endl; cout << "That account is deleted \n"; p[i].deleted = true; cin.ignore(); //To skip remaining '\n' character } else { cout << "I'm sorry, that is an invalid selection.\n" << "The accounts range from 0-9.\n" << "Please select this option again.\n\n"; } } void withdrawalsTrans(accountInfo *p) { int i; //placeholder for the number wanted to be edited. cout << "Please enter the number of the account id you would like to edit." << "\nExample: 5\n"; cin >> i; if (i <= accountSize) { cout << "Money:"; cin.ignore(); //To skip remaining '\n' character int x; cin >> x; if (x < p[i].balance) { p[i].balance = p[i].balance - x; cout << "balance changed to: " << p[i].balance << "\n"; } else { cout << "\n the requested money is bigger than balance"; } cin.ignore(); //To skip remaining '\n' character } else { cout << "I'm sorry, that is an invalid selection.\n" << "The accounts range from 0-9.\n" << "Please select this option again.\n\n"; } } void depositTrans(accountInfo *p) { int i; //placeholder for the number wanted to be edited. cout << "Please enter the number of the account id you would like to deposit." << "\nExample: 5\n"; cin >> i; if (i <= accountSize) { cout << "Money:"; cin.ignore(); //To skip remaining '\n' character int x; cin >> x; p[i].balance = p[i].balance + x; cout << "balance changed to" << p[i].balance << "\n"; cin.ignore(); //To skip remaining '\n' character } else { cout << "I'm sorry, that is an invalid selection.\n" << "The accounts range from 0-9.\n" << "Please select this option again.\n\n"; } } void transferTrans(accountInfo *p) { int i; //placeholder for the number wanted to be edited. cout << "Please enter the number of the account id you would like to send money from." << "\nExample: 5\n"; cin >> i; if (i <= accountSize) { cout << "Money:"; cin.ignore(); //To skip remaining '\n' character int x; cin >> x; cout << "to account number:"; cin.ignore(); //To skip remaining '\n' character int ac2; cin >> ac2; if (x < p[i].balance) { p[i].balance = p[i].balance - x; p[ac2].balance = p[ac2].balance + x; cout << "transfered " << x << " from " << p[i].name << " to " << p[ac2].name << "\n"; } else { cout << "\n the requested money is bigger than balance"; } cin.ignore(); //To skip remaining '\n' character } else { cout << "I'm sorry, that is an invalid selection.\n" << "The accounts range from 0-9.\n" << "Please select this option again.\n\n"; } }