Question: Implement a class Bank . This bank has two objects, checking and savings of type Account that was developed (will post underneath). Implement four member

Implement a class Bank. This bank has two objects, checking and savings of type Account that was developed (will post underneath). Implement four member functions:

deposit(double amount, string account) withdraw(double amount, string account) transfer(double amount, string account) print_balance() Here is the account string is "S" or " C". For the deposit or withdrawl, it indicates which account is affected. For a transfer it indicates the account from which the money the money is taken; the money is automatically transfer to the other account.

Test your program by using the main function below.

int main() { Bank my_bank; cout << "Inital bank balances: "; my_bank.print_balances(); /* set up empty accounts */ cout << "Adding some money to accounts: "; my_bank.deposit(1000, "S"); /* deposit $1000 to savings */ my_bank.deposit(2000, "C"); /* deposit $2000 to checking */ my_bank.print_balances(); cout << "Taking out $1500 from checking,and moving $200 from"; cout << " savings to checking. "; my_bank.withdraw(1500, "C"); /* withdraw $1500 from checking */ my_bank.transfer(200, "S"); /* transfer $200 from savings */ my_bank.print_balances(); cout << "Trying to transfer $900 from Checking. "; my_bank.transfer(900,"C"); my_bank.print_balances(); cout << "trying to transfer $900 from Savings. "; my_bank.transfer(900,"S"); my_bank.print_balances(); return 0; }

And here is the Account type:

#include #include using namespace std;

class Account{ public: double amount, rate; Account(){ amount = 10000; rate = 6; } Account(double a, double r){ amount = a; rate = r; }

double findDoublingTime() { double monthlyRate = rate / 1200; double months = log(2)/log(1 + monthlyRate); double years = months/12; return years; }

void deposit(double a){ if(a < 0){ return; } amount += a; }

void withdraw(double a){ if(amount-a < 0){ return; } amount -= a; }

double get_balance(){ return amount; } };

int main() { double balance, rate;

cout << "Enter initial balance: $"; cin >> balance;

cout << "Enter annual interest rate: "; cin >> rate;

Account my_account(balance, rate); // Set up my account

cout << "The time required to double the amount is: " << my_account.findDoublingTime() << " years." << endl;

return 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!