Question: #include #include #include // std::setprecision using namespace std; class Account { private: string last_name; string first_name; double balance; string account_number; public: Account(string ac) { account_number

#include #include #include // std::setprecision

using namespace std;

class Account { private: string last_name; string first_name; double balance; string account_number; public: Account(string ac) { account_number = ac; }

void displayAccount() { cout << "Account number : " << account_number << endl; cout << "Account Holder First name : " << first_name << endl; cout << "Account Holder Last name : " << last_name << endl; cout << "Account Balance : " << balance << endl;

}

void setFirstName(string str) { first_name = str; } void setLastName(string str) { last_name = str; } void setBalance(double b) { balance = b; } string getFirstName() { return first_name; } string getLastName() { return last_name; } string getAccountNumber() { return account_number; } double getBalance() { return balance; } friend ostream& operator<<(ostream& os, const Account& at);

}; Account* acc[5]; int no_of_accounts = 0; int saving_acc = 1000; int current_acc = 1000;

// This is the overloaded opearator required as part of the question.

ostream& operator<<(ostream& os, const Account& at) { os << "Account Number : " << at.account_number << " First Name :" << at.first_name << " Last Name: " << at.last_name << " Account Balance : " << std::fixed << at.balance << " ";

return os; }

void displayBankAccounts() { cout << " -------DETAILS----------------" << endl; for (int i = 0; i < no_of_accounts; i++) { cout << *acc[i]; } }

void AddNewAccount() { cout << " -----------------------" << endl; if (no_of_accounts == 5) { cout << "Cannot add more than 5 accounts" << endl; return; } int response; string str; double bal; cout << "Do you want to add a Savings Account or Checking Account?" << endl; cout << "Type 1 for Savings and 2 for Checking" << endl; cin >> str;

string ac_no; if (!str.compare("1")) { ac_no = "SAV"; ac_no += to_string(saving_acc);

saving_acc++; } else if (!str.compare("2")) { ac_no = "CUR"; ac_no += to_string(current_acc); current_acc++; } else { cout << "Invalid response" << endl; return; } acc[no_of_accounts] = new Account(ac_no); cout << "Enter Account Holder first name" << endl; cin >> str; acc[no_of_accounts]->setFirstName(str); cout << "Enter Account Holder Last name" << endl; cin >> str; acc[no_of_accounts]->setLastName(str); cout << "Enter Account Initial balance" << endl; cin >> bal; acc[no_of_accounts]->setBalance(bal); no_of_accounts++; }

void EditBankaccount() { string ac; char response; double bal; cout << "Enter Bank Account number to be edited" << endl; cin >> ac; for (int i = 0; i < no_of_accounts; i++) { if (acc[i]->getAccountNumber() == ac) { while (1) { cout << " -----------------------" << endl; cout << "1. Edit First Name" << endl; cout << "2. Edit Last Name" << endl; cout << "3. Deposit Money" << endl; cout << "4. Withdraw" << endl; cout << "5. Exit" << endl; cin >> response; string str; switch (response) { case '1': cout << "Enter First Name" << endl; cin >> str; acc[i]->setFirstName(str); break; case '2': cout << "Enter Last Name" << endl; cin >> str; acc[i]->setLastName(str); break; case '3': cout << "Enter Deposit Amount" << endl; cin >> bal; acc[i]->setBalance(acc[i]->getBalance() + bal); cout << "Amount deposited" << endl;

break; case '4': cout << "Enter Withdrawal Amount" << endl; cin >> bal; if (acc[i]->getBalance() < bal) { cout << "Account balance is less than amount of withdrawal" << endl; } else { acc[i]->setBalance(acc[i]->getBalance() - bal); cout << "Amount withdrawn" << endl; } break; case '5': default: cout << "Bye" << endl; return; } } } } cout << "Account does not exist" << endl; }

int main() {

//Menu Option

int option; while (1) { cout << "------------------------------" << endl; cout << "Menu : Select an option" << endl; cout << "1. Display bank Accounts" << endl; cout << "2. Add New Bank Account" << endl; cout << "3. Edit existing Bank Account" << endl; cout << "4. Exit" << endl; cin >> option; switch (option) { case 1: displayBankAccounts(); break; case 2: AddNewAccount(); break; case 3: EditBankaccount(); break; case 4: default: cout << "Good Bye!" << endl; return 0; } }

return 0; }

Can you modify this program so that it gives the user the option to sort by account balance

and so that for the savings account, profit accrued to date is tracked. Profit is determined and

manually added to total balance at the end of each month. Start at 0.

For checking account, number of checks written is tracked. Each time a check is

written, program user can increment the number of checks.

Start at 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!