0% found this document useful (0 votes)
24 views

Lab 2 - Final: Deposit

The document describes modifications to a BankAccount class to: 1. Add sequential account numbers and track the number of transactions. 2. Allow transferring money between accounts by calling existing deposit and withdraw methods. 3. Add fields for the last transaction details, customer name and address, and override toString() to print this information. 4. Demonstrate the class by creating accounts for the student and their parent, performing transactions, and printing the updated account details.

Uploaded by

Abhinav Pathak
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Lab 2 - Final: Deposit

The document describes modifications to a BankAccount class to: 1. Add sequential account numbers and track the number of transactions. 2. Allow transferring money between accounts by calling existing deposit and withdraw methods. 3. Add fields for the last transaction details, customer name and address, and override toString() to print this information. 4. Demonstrate the class by creating accounts for the student and their parent, performing transactions, and printing the updated account details.

Uploaded by

Abhinav Pathak
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab 2_final

1. Create a BankAccount class having


Constructor: Which will accept a double value for balance.
Methods:
a) deposit: Which will accept a double value
b) withdraw: Which will accept a double value, check if balance is greater
than the value +minimum balance
c) getBalance: which will return the balance.
2. Modify the BankAccount class created on 31/8 to
Implement unique and sequential account numbers for all BankAccounts
created (Starting with 180020131111).
Variable to store numberOfTransactions. Modify all the methods to
increment this for any transaction.
Method for transfer money between two bank accounts.
This method should use the existing methods, withdraw and
deposit.
It should check if there is sufficient balance before transferring.
Increment numberOfTransactions for both accounts
3. Modify the BankAccount class
Implement a Class LastTransaction which will have a String variables
one for type of last transaction: Withdraw, Deposit or Transfer are possible
values.
Implement a class PersonalDetails. This will have 2 String variables:
name and address. Override the toString () method.
Modify the BankAccount class to have objects of LastTransaction and
PersonalDetails as fields. Override the toString () method to print
Account number, Name, Address, Last transaction.
Modify the constructor to accept the details for name and address.
Modify the methods withdraw, deposit or transfer such that this field is
updated. Override the toString () method.
4. Create 2 BankAccounts with initial deposits 5000 and 2000 and with names
and address of your parent and yourself. Do withdraw, deposit and transfer.
After each operation print the toString() of your account.

You might also like