Question: Array Method ONLY Design a class named Account that contains: A private int data field named id for the account number(default 0). A private data

Array Method ONLY

Design a class named Account that contains: A private int data field named id for the account number(default 0). A private data field name of the String type to store the name of the customer.

From this class a number of accounts classes may be derived for the same customer. For example an account in Dirham (AED) currency, Dollar (USD) currency, Euro (EUR) currency and deposit saving account. The deposit saving account has to be in Dirhams. Each of these accounts has the following data fields:

  • - A private double data field named balance for the account (default 0).

  • - A private Date data field named dateCreated that stores the date when the account

    was created.

  • - A private double data field named annualInterestRate that stores the current interest

    rate (default 0) for the saving deposit account only.

  • - Transactions whose type is ArrayList that stores the transactions for the accounts.

    Each transaction is an instance of the Transaction class. The Transaction class is defined as follows:

Data Field -date: java.util.Date

-type: char

-amount: double -balance: double -currency: String

Description

The date of this transaction. . The type of the transaction, such as 'W' for withdrawal, 'D' for deposit.

The amount of the transaction. The new balance after this transaction The account currency to which this transaction will apply

The transaction class has the following constructor: +Transaction (type: char, amount: double, balance: double, currency:String)

The following methods are needed in the accounts (you decide where each should go) and if more methods are needed: - A no-arg constructor that creates a default account. - A constructor that creates an account with the needed attributes (you decide)

- The accessor and mutator methods for private members. - withdraw () and deposit () methods to add a transaction to the transactions array list and execute it on the required account by updating the balance.

Include within the deposit saving account: - A method named getMonthlyInterestRate() that returns the monthly interest rate. - A method named getMonthlyInterest() that returns the monthly interest.

The Monthly interest is calculated as: balance * monthlyInterestRate. monthlyInterestRate is calculated as: annualInterestRate / 12.

Note that annualInterestRate is a percentage, e.g., like 4.5%. You need to divide it by 100.

Write a test program that creates account objects for a number of customers. Some have a single account, some have multiple accounts and some have multiple accounts with a deposit saving account.

- Use a text file to read the test data from which accounts are created - Use another text file onto which the transactions are stored - Use inheritance and polymorphism - Use the following validation rules:

o Currency match between an account and the transaction to be executed o Opening a deposit saving account in dollars is disallowed o Withdrawing from zero balance account is disallowed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!