×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Bank Management Assignment Solution Using C++

July 10, 2024
Dr. Isabella Wong
Dr. Isabella
🇦🇺 Australia
C++
Dr. Isabella Wong, a PhD holder in Software Engineering from an esteemed Australian university, has completed over 600 orders in C++ assignments. With expertise in multithreading and Qt Quick/QML development, she excels in optimizing performance and creating visually appealing user interfaces in Qt applications.
Key Topics
  • Question:
Tip of the day
Focus on understanding TensorFlow's computational graph and its eager execution mode. Use pre-built functions like tf.data for efficient data pipelines.
News
The latest version of Google's machine learning library, offering improved performance, streamlined APIs, and expanded support for reinforcement learning, making it a powerful tool for AI development.

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 C++ assignment 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 <iostream> #include <string> 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 &lt;&lt; "Please select a choice from this submenu.\n" &lt;&lt; "1) Enter account Information.\n" &lt;&lt; "2) Change account Information.\n" &lt;&lt; "3) Print account Information.\n" &lt;&lt; "4) Delete account Information.\n" &lt;&lt; "5) Withdrow Transaction.\n" &lt;&lt; "6) deposits Transaction.\n" &lt;&lt; "7) transfer Transaction.\n" &lt;&lt; "10) Leave this menu.\n" &lt;&lt; "Selection: "; cin &gt;&gt; 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 &lt;&lt; "\n Number of accouunts:"; cin &gt;&gt; accountSize; // int size = 10; // Array size for (index = 0; index &lt; accountSize; index++) { cout &lt;&lt; "Please enter the following information of account id " &lt;&lt; index &lt;&lt; " : \n"; cout &lt;&lt; "account Name:"; cin.ignore(); //To skip remaining '\n' character getline(cin, p[index].name); cout &lt;&lt; "\naccount Telephone Number:"; // cin.ignore(); //To skip remaining '\n' character getline(cin, p[index].tell); cout &lt;&lt; "\nbirth:"; getline(cin, p[index].birth); cout &lt;&lt; "\naccount Type:"; getline(cin, p[index].accounttype); p[index].accountnumber = index; // cin.ignore(); //To skip remaining '\n' character cout &lt;&lt; "\nAccount Address:"; getline(cin, p[index].address); cout &lt;&lt; "\nBalance:"; cin &gt;&gt; p[index].balance; } } void printAccount(accountInfo *p) { int index = 0; //int size = 10; // Array size for (index = 0; index &lt; accountSize; index++) { if (!p[index].deleted) { cout &lt;&lt; "The information entered for each account is: \n"; cout &lt;&lt; "Account id " &lt;&lt; index &lt;&lt; endl; cout &lt;&lt; "Name: " &lt;&lt; p[index].name &lt;&lt; endl; cout &lt;&lt; "Telephone Number: " &lt;&lt; p[index].tell &lt;&lt; endl; cout &lt;&lt; "Account Number: " &lt;&lt; p[index].accountnumber &lt;&lt; endl; cout &lt;&lt; "Account Type: " &lt;&lt; p[index].accounttype &lt;&lt; endl; cout &lt;&lt; "Address: " &lt;&lt; p[index].address &lt;&lt; endl; cout &lt;&lt; "Birth: " &lt;&lt; p[index].birth &lt;&lt; endl; cout &lt;&lt; "Account Balance: " &lt;&lt; p[index].balance &lt;&lt; endl; } } } void editAccount(accountInfo *p) { int i; //placeholder for the number wanted to be edited. cout &lt;&lt; "Please enter the the account id you would like to edit." &lt;&lt; "\nExample: 5\n"; cin &gt;&gt; i; if (i &lt;= accountSize) { cout &lt;&lt; endl; cout &lt;&lt; "Please enter the updated information of the account: \n"; cout &lt;&lt; "Account Name:"; cin.ignore(); //To skip remaining '\n' character getline(cin, p[i].name); cout &lt;&lt; "\nAccount Telephone Number:"; getline(cin, p[i].tell); cout &lt;&lt; "\nAccount Type:"; getline(cin, p[i].accounttype); cout &lt;&lt; "\nAccount address:"; getline(cin, p[i].address); cout &lt;&lt; "\nbirth:"; getline(cin, p[i].birth); cout &lt;&lt; "\nBalance:"; cin &gt;&gt; p[i].balance; } else { cout &lt;&lt; "I'm sorry, that is an invalid selection.\n" &lt;&lt; "The accounts range from 0-9.\n" &lt;&lt; "Please select this option again.\n\n"; } } void delaccount(accountInfo *p) { int i; //placeholder for the number wanted to be edited. cout &lt;&lt; "Please enter the number of the account id you would like to edit." &lt;&lt; "\nExample: 5\n"; cin &gt;&gt; i; if (i &lt;= accountSize) { p[i].deleted = true; cout &lt;&lt; endl; cout &lt;&lt; "That account is deleted \n"; p[i].deleted = true; cin.ignore(); //To skip remaining '\n' character } else { cout &lt;&lt; "I'm sorry, that is an invalid selection.\n" &lt;&lt; "The accounts range from 0-9.\n" &lt;&lt; "Please select this option again.\n\n"; } } void withdrawalsTrans(accountInfo *p) { int i; //placeholder for the number wanted to be edited. cout &lt;&lt; "Please enter the number of the account id you would like to edit." &lt;&lt; "\nExample: 5\n"; cin &gt;&gt; i; if (i &lt;= accountSize) { cout &lt;&lt; "Money:"; cin.ignore(); //To skip remaining '\n' character int x; cin &gt;&gt; x; if (x &lt; p[i].balance) { p[i].balance = p[i].balance - x; cout &lt;&lt; "balance changed to: " &lt;&lt; p[i].balance &lt;&lt; "\n"; } else { cout &lt;&lt; "\n the requested money is bigger than balance"; } cin.ignore(); //To skip remaining '\n' character } else { cout &lt;&lt; "I'm sorry, that is an invalid selection.\n" &lt;&lt; "The accounts range from 0-9.\n" &lt;&lt; "Please select this option again.\n\n"; } } void depositTrans(accountInfo *p) { int i; //placeholder for the number wanted to be edited. cout &lt;&lt; "Please enter the number of the account id you would like to deposit." &lt;&lt; "\nExample: 5\n"; cin &gt;&gt; i; if (i &lt;= accountSize) { cout &lt;&lt; "Money:"; cin.ignore(); //To skip remaining '\n' character int x; cin &gt;&gt; x; p[i].balance = p[i].balance + x; cout &lt;&lt; "balance changed to" &lt;&lt; p[i].balance &lt;&lt; "\n"; cin.ignore(); //To skip remaining '\n' character } else { cout &lt;&lt; "I'm sorry, that is an invalid selection.\n" &lt;&lt; "The accounts range from 0-9.\n" &lt;&lt; "Please select this option again.\n\n"; } } void transferTrans(accountInfo *p) { int i; //placeholder for the number wanted to be edited. cout &lt;&lt; "Please enter the number of the account id you would like to send money from." &lt;&lt; "\nExample: 5\n"; cin &gt;&gt; i; if (i &lt;= accountSize) { cout &lt;&lt; "Money:"; cin.ignore(); //To skip remaining '\n' character int x; cin &gt;&gt; x; cout &lt;&lt; "to account number:"; cin.ignore(); //To skip remaining '\n' character int ac2; cin &gt;&gt; ac2; if (x &lt; p[i].balance) { p[i].balance = p[i].balance - x; p[ac2].balance = p[ac2].balance + x; cout &lt;&lt; "transfered " &lt;&lt; x &lt;&lt; " from " &lt;&lt; p[i].name &lt;&lt; " to " &lt;&lt; p[ac2].name &lt;&lt; "\n"; } else { cout &lt;&lt; "\n the requested money is bigger than balance"; } cin.ignore(); //To skip remaining '\n' character } else { cout &lt;&lt; "I'm sorry, that is an invalid selection.\n" &lt;&lt; "The accounts range from 0-9.\n" &lt;&lt; "Please select this option again.\n\n"; } }

Related Samples

Access our free C++ assignment samples to enhance your coding skills and knowledge. These samples cover various topics and provide practical examples to help you understand complex concepts. Perfect for students and beginners looking to improve their programming proficiency. Check them out now!