Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a class Account. An account has a balance, functions to add and withdraw money, and a function to query the current balance. Charge $20

Implement a class Account. An account has a balance, functions to add and withdraw money, and a function to query the current balance. Charge $20 penalty if an attempt is made to withdraw more money than available in the account. Test your Account class by using the following main function. int main() { Account my_account(100); // Set up my account with $100 my_account.deposit(50); my_account.withdraw(175); // Penalty of $20 will apply my_account.withdraw(25);

cout << "Account balance: " << my_account.get_balance() << " "; my_account.withdraw(my_account.get_balance()); // withdraw all cout << "Account balance: " << my_account.get_balance() << " "; return 0; }

2. Enhance the Account class to compute the interest on the current balance. An account has initial balance of $10,000.00, and 6% percent annual interest is compounded monthly until the investement is double. Write a main function to determine the number of months to double the initial investment. Create a menu to allow the user to enter the initial investement and the annual interest rate.

3. Implement a class Bank. This bank has two objects, checking and savings of type Account that was developed in the problem 2. 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; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

=+Where do you want to live and work?

Answered: 1 week ago

Question

=+1 Where are the best places in the world to live (and work)?

Answered: 1 week ago