Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design a class named BankAccount that contains: 1. A private int data field named accountId for the account. 2. A private double data field named

Design a class named BankAccount that contains: 1. A private int data field named accountId for the account. 2. A private double data field named accountBalance for the account (default 0). 3. A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. 4. A private Date data field named dateCreated that stores the date when the account was created. 5. A private int data field named numberOfDeposits that counts how many deposits have been performed in the account (initialized to 0); 6. A private int data field named numberOfWithdrawals that counts how many withdrawals have been performed in the account (initialized to 0); 7. A no-arg constructor that creates a default account and initializes the accountId with a 4 digit random integer and the date when the account was created. 8. A two-argument constructor that creates an account with a specific initial balance and annual interest rate (constructor arguments) and also initializes the accountId with a 4 digit random integer and the date when the account was created. 9. The accessor and mutator methods for annualInterestRate. 10. The accessor (no mutator) methods for accountBalance, dateCreated, numberOfDeposits, numberOfWithdrawals and accountId. 11. A method named getMonthlyInterestRate() that returns the monthly interest rate. Where monthly interest rate is the annual interest rate divided by 12. 12. A method named getMonthlyInterest() that returns the monthly interest (i.e. account balance * monthly interest rate). 13. A method named withdraw(double) that withdraws a specified amount from the account*. 14. A method named deposit(double) that deposits a specified amount to the account*. *Provide appropriate input validation for these methods. Print a message to the console if the arguments passed to the method do not pass the validation test(s).

Write a test program (class TestBankAccount) that creates a BankAccount object with a balance of $20,000, and an annual interest rate of 4.5%. Use the withdraw method to withdraw $2,500, use the deposit method to deposit $3,000 and then print the account id, Balance, monthly interest rate, monthly interest, number of withdrawals, number of deposits and the date when this account was created (use console output, see below). Sample output: Account ID: 1234 Balance: $20,500 Monthly Interest Rate: 0.375% Monthly Interest: $76.88 Number of Withdrawals: 1 Number of Deposits: 1 Created On: 9/11/2018

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions

Question

Comment should this MNE have a global LGBT policy? Why/ why not?

Answered: 1 week ago