cs175:implementing_classes_lab_2
Programming Lab Exercise
BankAccount1.java, TestBankAccount1.java
In DrJava, define a class called BankAccount1 in BankAccount1.java. Use the source code at http://tinyurl.com/l4huluv as a starting point.
An object of this class represents a bank account.
Add the following to the BankAccount1 class definition:
- an instance variable that represents an account number
- a set method to set the account number
- a get method to get the account number
- an instance variable that represents the account holder's full name
- a set method to set the account holder's full name
- a get method to get the account holder's full name
- re-compile the code after each addition you make
In TestBankAccount1.java do the following:
- Prompt for an enter the following information from the keyboard using Scanner input:
- a full name of an account holder
- an account number
- an account balance
- Using the information that was entered, create a bank account in the account holder's
name, assign it the input account number, and deposit the input account balance into it.
- Use the get methods for account holder's name, account number and account balance to
display all bank account information.
Example output:
name: Bea Rogers
account number: 100
account balance: $1000
See source code for BankAccount1.java, TestBankAccount1.java
cs175/implementing_classes_lab_2.txt · Last modified: by jchung
