A Bank Account Class
This lab gives you practice with writing and calling simple
methods. It also gives you practice with using methods to access private data
members.
- File Account.java contains
a partial definition for a class representing a bank account. Save it to your
directory and study it to see what methods it contains. Then complete the
Account class as described below. Note that you won't be able to test your
methods until you write ManageAccounts in question #2.
- Fill in the code for method printSummary,
which should print the name, account number, and balance for the account.
- Fill in the code for method chargeFee, which
should deduct a service fee from the account. If the balance is $1000
or more, no fee should be charged, but if it is less than $1000, $10 should
be deducted from the balance.
- Modify chargeFee so that instead of returning
void, it returns the new balance. Note that you will have to make changes
in two places.
- Fill in the code for method changeName which
takes a string as a parameter and changes the name on the account to be
that string.
- File ManageAccounts.java
contains a shell program that uses the Account class above. Save it to your
directory, and complete it as indicated by the comments.
- Modify ManageAccounts so that it prints the balance
after the calls to chargeFees. Instead of using the getBalance method like
you did after the deposit and withdrawal, use the balance that is returned
from the chargeFees method. You can either store it in a variable and then
print the value of the variable, or embed the method call in a println statement.

Go back to lab1 index
page