|
|
Java Student Project |
||
|
|||
Account |
|||
|
|
|
||
| Ability Level: | Intermediate | ||
|
|
|
||
| Estimated Time: | 50 minutes | ||
|
|
|
||
| Objectives: |
|
||
|
|
|
||
| Materials & Resources: |
|
||
|
|
|
||
| Overview: | 1.
Create a class called Account1 that stores information about a
bank account. It should have a data member to store the account
balance named balance, and the account number, named
accountNumber. The class should also have a static data member
called nextAccountNumber initialized to zero. Create a
constructor for the class that takes a balance amount as an
argument, and sets the accountNumber variable to the
nextAccountNumber plus 1. Save this class in a file named
Account1.java.
2. Add a method called display that will display the account number and balance. Create another class called OpenAccount that will create three Account1 objects with balances of 4000, 5000, and 2000. The constructor should assign consecutive account numbers. Save this class in a file called OpenAccount.java. Add another constructor that will allow Account1 objects to be instantiated without a balance argument, so that the balance is initialized to zero, but the account number receives the next available number. Use the this reference in the constructor to call the constructor that takes the double argument.3. Add a static variable called interestRate and initialize it to .08 (8% interest). Add a method called calcInterest that will calculate the interest, display the interest amount, add the interest to the balance and display the new balance.4. Add a method that will report what the last account number
assigned was, and also what the current interest rate is. Call
this method reportStatus. |
||
|
|
|
||
| Instructions: | See the notes in overview above. | ||
|
|
|
||
| Hints: | Some important
points to keep in mind in doing this project:
|
||