Lab 11 - Building a bank manager

Now that we have a basic idea of how classes work, your job is to expand on the BankManager class we built in class and turn it into an interactive program we could use to play banker. Here is what you are to do:

Write a driver program

Build a simple menu driven program that asks the user to input a single letter (upper of lower case is fine). You figure out what letter they entered and do one of the following things:

  • q - quit the program
  • n - start a new day (see below)
  • a - list all accounts and their current balance. Also show the total funds in the bank.
  • c - open a new checking account
  • s - open a new savings account
  • d - make a deposit into an account
  • w - make a withdrawal from an account

Your program should loop until it is done.

Tracking days

We will need to keep track of what day it is. We will use the n choice to move to the next day (since waiting a full day would be kind of silly!). Tracking days is important because each day we will pay out interest on savings accounts.

Rules of the bank

Interest is paid for savings accounts at a rate of 4% per year. (Where is this bank - I want an account there!)

The formula for paying interest is:

interest = balance * (rate/365)

This gets added to the balance each day (but only for savings accounts). You will update the balance in the savings accounts as you start a new day with the n command.

While this bank does pay interest, it also charges a fee for each transaction. That fee is $0.25. Finally, if you try to overdraw any account, you are charged a $10 fee and your account is locked until you deposit $25 or more.

How to write the program.

Remember our discussion on how to approach writing these programs. Take things slow and test often. You can sprinkle print statements around to see what is going on.

Start off by writing the code and make sure you can ask the user for a choice and keep looping until they enter a q.

Then, add a simple BankManager class with methods that will handle each menu selection (well, not the q command). Add code to the methods that asks the user for anything needed to figure out what to do.

Finally, add the basic BankAccount class and build a real account object as shown in class. You will need to make changes to get the code working according to the new rules.

If you need any additional methods, add them as necessary in either class file.

What to turn in

This program needs three files:

  • - the main driver program
  • - modified as needed from the class example
  • - modified as needed from the class example

Place all of these files in a single directory on your “H” drive.

When the program starts up, it should create a new BankManager object using the code shown in class. The methods in the BankManager class should be modified to ask the user anything needed to complete the step. For instance, when the user selects o, we need to know if this is a checking or savings account.