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 no-arg constructor that creates a default account and initializes the accountId with a 4 digit random integer.

6. A one-argument constructor that creates an account with a specific initial balance (constructor argument) and initializes the accountId with a 4 digit random integer.

7. The accessor and mutator methods for accountBalance and annualInterestRate.

8. The accessor methods for dateCreated and accountId.

9. A method named getMonthlyInterestRate() that returns the monthly interest rate. Where monthly interest rate is the annual interest rate divided by 12.

10. A method named withdraw(double) that withdraws a specified amount from the account

11. A method named deposit(double) that deposits a specified amount to the account.

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, the monthly interest, and the date when this account was created (use console output, see below).

Draw the UML diagram for both classes.

Sample output:

Account ID: 1234

Balance: $20,500

Monthly Interest: 0.375%

Created On: 9/22/2016

Submission guidelines: Send your files (BankAccountUML.docx (or visio), BankAccount.java and TestBankAccount.java) as attachments.

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

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

Students also viewed these Databases questions