Menu

[Solved] Part 1 Design Encapsulated Class Named Account Represent Bank Account Class Contains 1 Pri Q37208301

Part 1:

Design an encapsulated class named Account to represent a bankaccount. The class contains:
1. A private int data field named accountNumber for the account(default 0).
2. A private double data field named balance for the account(default 0).
3. A private double data field named annualInterestRate that storesthe current interest rate (default 0). Assume all accounts have thesame interest rate.
4. A private Date data field named dateCreated that stores the datewhen the account was created.
5. A default constructor that creates a default account.
6. A constructor that creates an account with the specified accountnumber and initial balance.
7. The accessor and mutator methods for all attributes ( settersand getters )
8. A method named getMonthlyInterestRate() that returns the monthlyinterest rate.
9. A method named withdraw that withdraws a specified amount fromthe account.
10. A method named deposit that deposits a specified amount to theaccount.
11. A method named toString that displays balance, the monthlyinterest, and the date when this account was created.

You are required to do the followings:
A. Draw the UML diagram for the class.
B. Implement the class Account
C. Write a test class that creates Two Account objects. The firstobject has the following
properties:
a. Account number of 1234,
b. A balance of AED 20,000, and
c. An annual interest rate of 4.5%.
d. Use the withdraw method to withdraw AED 2,500,
e. Use the deposit method to deposit AED 7,450,
D. Create the second object using the default constructor. Thenread the appropriate attributes
for the second object from the keyboard
E. Prompt the user of how much he/she needs to withdraw from theaccount. Use the withdraw
method to withdraw the requested amount
F. Prompt the user of how much he/she need to deposit into theaccount. Use the deposit
method to deposit the requested amount
G. The test program should display the balance, the monthlyinterest, and the date when this
account was created via implementing the toString method in theclass
Part 2:

Modify the Account class that was created in part one as per theUML digram shown below. The
new modifications in the Account class includes thefollowings:
1. Add a new data field accountholder of type Person that storesthe name and contact
number of the customer.
2. Add a new constructor that constructs an account with thespecified account holder, account
number, and balance, and date created.
3. Add a new data field named transactions whose type is ArrayListthat stores the transaction
for the accounts. Each transaction is an instance of theTransaction class.
4. Modify the withdraw and deposit methods to add a transaction tothe transactions array list.
The class Person has the followings:
1. Private Name data field named name which refers to first andlast name of the customer
2. Private String data field named contactNumber that holds thecontact number of the
customer
The class Transaction attributes are as follows:
1. Private Date data field named date which refers to the date ofthe transaction
2. Private char data field named type, which takes the values ‘W’for withdraw or ‘D’ for deposit
3. Private double data field named amount which refers to thetransaction amount
4. Private double data field name balance which refers to thebalance following the transaction
Both classes DateCreated and Name are self-explained. Note that youhave the option of either
use the class DateCreated or using the Date class via importingjava library. This can be done by
inserting the following statement at the beginning of the classfile:
import java.util.Date;
After completing all classes in the UML. You are required to do thefollowings:
Write a test program that creates an Account with the followingsdata:
a. Customer name is Mohamed Ali
b. contact number is +9715623658876
c. account number : 87965
d. balance : AED 22500.00
e. Deposit the followings : 5400.00, 405.00, 7569.00 to theaccount
f. Withdraw 560.00, 450.00, 1250.00 from the account.
g. Print an account summary that shows account holder name,balance, and all transactions.

Expert Answer


Answer to Part 1: Design an encapsulated class named Account to represent a bank account. The class contains: 1. A private int dat… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *