Question
Create a C++ program to process bank accounts (similar to the Lab Assignment #7) but with additional functions. You may want to solve this problem step-by-step using the following guidelines: 1. First use the Lab Assignment #7. 2. Secondly, remove the arrays of Checking and Savings objects. Replace them with array of Account objects. 3. Change choice #1 and #2 so that the new checking and savings accounts are stored in array of Account. 4. Combine choice #3 and #5 so that array of Account is used. 5. Combine choice #4 and #6 so that array of Account is used. 6. Change the printBalance functions so that polymorphism virtual functions are used. 7. Add a new calculateDailyInterest functions so that polymorphism virtual functions are used. The functions also add the daily interest to the account balance. The savings account is getting 3% annual interest rate. The checking account is getting 2% annual interest rate for amount that over $500 . 8. Add a choice #7 to transfer money between accounts. Make sure you check for not enough money to transfer Original code to save time- ------------------------------------------------------------------------------------------------------------------------------------------------------------ // //Account.cpp #include using namespace std; #include using std::setprecision; using std::fixed; #include "Account.h" Account::Account( int num, double bal ) { setAccountNum( num ); setBalance( bal ); } void Account::operator+=( double Amount ) { balance += Amount; } void Account::operator-=( double Amount ) { balance -= Amount; } void Account::printBalance( string acctype ) { cout << acctype << " Account #" << AccountNum << " Balance = $" << fixed << setprecision(2) <<balance << endl; } int Account::getAccountNum() { return AccountNum; } double Account::getBalance() { return balance; } void Account::setAccountNum( int num ) { AccountNum = num; } void Account::setBalance( double b ) { balance = b; } ------------------------------------------------------------------------------------------------------------------------------------------------------------- // //Checking.cpp #include using namespace std; #include "Checking.h" Checking::Checking( int num, double bal ) : Account(num,bal) { } ------------------------------------------------------------------------------------------------------------------------------------------------------------------- // //Savings.cpp #include using namespace std; #include "Savings.h" Savings::Savings( int num, double bal ) : Account(num,bal) { } ---------------------------------------------------------------------------------------------------------------------------------------------------------------- // AccountTest.cpp // #include using namespace std; #include using std::vector; #include "Account.h" #include "Checking.h" #include "Savings.h" int main( ) { vector < Checking * > checking(50) ; vector < Savings *> savings(50); int accNumS = 0, accNumC = 0; double bal = 0, amt = 0; int acct, i; string outstr = " ################################################# "; outstr += "# Enter one of the following # "; outstr += "# 1) Create a new Checking Account # "; outstr += "# 2) Create a new Savings Account # "; outstr += "# 3) Make a Deposit to you Accounts # "; outstr += "# 4) Make a Withdraw from your Accounts # "; outstr += "# 7) Display all accounts # "; outstr += "# 8) Exit # "; outstr += "################################################# "; cout << outstr ; int ans; cout << "Enter choice: "; cin >> ans; cout << endl; while( ans != 8 ) { switch( ans ) { case 1: cout << "Enter balance for accont #" << accNumC+1 << ": "; cin >> bal; checking[accNumC] = new Checking(accNumC+1,bal); accNumC++; break; case 2: cout << "Enter balance for accont #" << accNumS+1 << ": "; cin >> bal ; savings[accNumS] = new Savings(accNumS+1,bal); accNumS++; break; case 3: cout << "Which checking account: "; cin >> acct; cout << "Amount of deposit: "; cin >> amt ; (*checking[acct-1]) += amt ; break; case 4: cout << "Which checking account: "; cin >> acct; cout << "Amount of withdrawal: "; cin >> amt; (*checking[acct-1]) -= amt ; break; case 5: cout << "Which savings account: "; cin >> acct; cout << "Amount of deposit: "; cin >> amt ; (*savings[acct-1]) += amt ; break; case 6: cout << "Which savings account: "; cin >> acct; cout << "Amount of withdrawal: "; cin >> amt; (*savings[acct-1]) -= amt ; break; case 7: cout << endl << "----------Checking--------" << endl; for( int i=0; i < accNumC; i++ ) checking[i]->printBalance("Checking"); cout << endl << "----------Savings---------" << endl; for( int i=0; i < accNumS; i++ ) savings[i]->printBalance("Savings"); cout << "***********************************************" << endl; break; case 8: break; } cout << outstr ; cout << "Enter choice:"; cin >> ans; } system("pause"); return( 0 ); } any help/solutions to the question would be greatly appreciated thank you.
Explanation / Answer
#include #include #include #include #include //*************************************************************** // CLASS USED IN PROJECT //**************************************************************** class account { int acno; char name[50]; int deposit; char type; public: void create_account(); //function to get data from user void show_account(); //function to show data on screen void modify(); //function to get new data from user void dep(int); //function to accept amount and add to balance amount void draw(int); //function to accept amount and subtract from balance amount void report(); //function to show data in tabular format int retacno(); //function to return account number int retdeposit(); //function to return balance amount char rettype(); //function to return type of account }; //class ends here void account::create_account() { coutacno; coutdeposit; cout