#include using namespace std; vector menu_items= { "New", "Withdrawal", "Deposit", "Check Balance", "Display All", "Fund Transfer", "Exit" }; const int EXIT_CODE = menu_items.size(); typedef struct { int id; string name; float balance; } MyAccount; map accounts; void add(); void withdraw(){}; void deposite(){}; void checkBalance(); void displayAll(); void fundTransfer(); void loadDataTable(); int ran = 0; int menu() { if (ran == 0) { loadDataTable(); ++ran; } int op = 0; int items = menu_items.size(); cout << "<----- MENU ----->\n"; for (int i = 0; i < items; i++) { cout << '\t' << i+1 << ". " << menu_items[i] << '\n'; } printf("Enter your choice (1-%d): ", items); cin >> op; if ( !(op >= 1 && op <= items) ) { cout << "Invalid Choice! Please select again!\n"; menu(); } return op; } int main() { int op = menu(); if (op == EXIT_CODE) { cout << "<----- Program Exit ----->\n"; return 0; } cout << "\n\n\t<----- " << menu_items[op-1] << " ----->\n"; switch (op) { case 1: add(); break; case 2: withdraw(); break; case 3: deposite(); break; case 4: checkBalance(); break; case 5: displayAll(); break; } main(); return 0; } void add() { MyAccount ac; while(true) { cout << "Enter your account ID: "; cin >> ac.id; if (accounts.find(ac.id) == accounts.end()) break; cout << "This account already exists! Enter a different ID.\n"; } cout << "Enter your name: "; cin >> ac.name; cout << "Enter your deposite amount: "; cin >> ac.balance; accounts[ac.id] = ac; cout << "\n\t\tAccount creation successful!\n"; return; } void checkBalance() { cout << "Enter your account ID: "; int id; cin >> id; if (accounts.find(id) == accounts.end()) { cout << "Account not found!\n\n"; return; } cout << "\n\n\tOwner name: " << accounts[id].name << '\n'; cout << "\tBalance: " << accounts[id].balance << '\n'; cout << "\n\n"; } void displayAll() { for (auto ac: accounts) { cout << "\n\n\tAccount ID: " << ac.second.id << '\n'; cout << "\tAccount Owner Name: " << ac.second.name << '\n'; cout << "\tBalance: " << ac.second.balance << '\n'; } cout << "\n\n"; } void fundTransfer() { // validify sender and receiver accounts. } void loadDataTable() { ifstream file("accounts.txt"); while(!file.eof()) { MyAccount ac; file >> ac.id >> ac.name >> ac.balance; accounts[ac.id] = ac; } }