Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A Java question. You are given a BankAccount class. You are to write two subclasses: TransactionAccount and InterestAccount BankAccount : This class is provided for

A Java question. You are given a BankAccount class. You are to write two subclasses: TransactionAccountand InterestAccount

BankAccount:

This class is provided for you. It is different from earlier versions in that it requires a minimum balance of $1500. There is a $10.00 fee for any month where the ending balance is below the minimum balance. There is an endOfMonth method to handle end of month processing. Its subclasses will handle end of month processing differently.

TransactionAccount:

This account is a subclass of BankAccount. It has no minimum balance, but there is a charges for every transaction after a certain number of free transactions. At the current time, the number of free transactions is 4 and the charge is a $5.00 for every transaction after that amount. Both deposits and withdrawals are transactions. There is no charge to get the balance. The fees are subtracted during end of month processing. Define and use constants.

InterestAccount:

This is a subclass of BankAccount. The owner of the account can deposit or withdraw money at any point. The account earns 0.9% interest annually compounded monthly. Interest is paid on the ending balance during end of month processing. Use a constant for annual interest rate.

Provide Javadoc. You can use @Override for overridden methods

---------------------------------------------------------------------------------------------------------------------------

The AccountTester and BankAccount have been given as follow:

AccountTester.java

/** * Tester for BankAccount and its subclasses */ public class AccountTester { public static void main(String[] args) { //check that these are subclasses of BankAccount BankAccount account = new TransactionAccount(1500, "abc123"); account.endOfMonth(); System.out.println("No transactions: " + account.getBalance()); System.out.println("Expected: 1500.0"); // for (int i = 0; i < TransactionAccount.FREE_TRANSACTIONS; i++) { account.withdraw(1); } account.endOfMonth(); System.out.println("Three Transaction: " + account.getBalance()); System.out.println("Expected: 1496.0"); //make new account account = new TransactionAccount(1500, "xyz789"); //withdraw $4 the add $4 using 6 transactions for (int i = 0; i < TransactionAccount.FREE_TRANSACTIONS ; i++) { account.withdraw(1); } account.deposit(2.0); account.deposit(2.0); System.out.println("Before end of month: " + account.getBalance()); System.out.println("Expected: 1500.0"); account.endOfMonth(); System.out.println("After end of month: " + account.getBalance()); System.out.println("Expected: 1490.0"); //InterestAccount testing BankAccount account2 = new InterestAccount(1000, "abc123"); account2.endOfMonth(); System.out.printf("after one month: %.2f%n" , account2.getBalance()); System.out.println("Expected: 1000.75"); account2 = new InterestAccount(1000, "qrs123"); account2.withdraw(100); //do a 12 end of month processings for(int i = 0; i < 12; i++) { account2.endOfMonth(); } account2.deposit(100); System.out.printf("%.2f%n" , account2.getBalance()); System.out.println("Expected: 1008.13"); } } 

BankAccount.java

/** * A bank account has a balance that can be changed by * deposits and withdrawals * */ public class BankAccount { private double balance; private String accountId; public final static double MINIMUM_BALANCE = 1500; public final static double BELOW_MINIMUM_FEE = 10.0; /** * Constructs a bank account with a given balance. * @param initialBalance the initial balance * @param id the id for this account */ public BankAccount(double initialBalance, String id) { balance = initialBalance; accountId = id; } /** * Gets the id for this account * @returns the id for this account */ public String getAccountId() { return accountId; } /** Deposits money into the bank account. @param amount the amount to deposit */ public void deposit(double amount) { balance = balance + amount; } /** Withdraws money from the bank account. @param amount the amount to withdraw */ public void withdraw(double amount) { balance = balance - amount; } /** Gets the current balance of the bank account. @return the current balance */ public double getBalance() { return balance; } /** * Do end of month processing for the account */ public void endOfMonth() { if (balance < MINIMUM_BALANCE) { balance = balance - BELOW_MINIMUM_FEE; } } } 

plz give me the answer of TransactionAccount and InterestAccount ,Thank you

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

do you match this please Na2O2, sodium oxide SCl2, sulfur chloride

Answered: 1 week ago

Question

Write a Python program to check an input number is prime or not.

Answered: 1 week ago

Question

=+working on a micro-multinational?

Answered: 1 week ago

Question

=+j Identify the challenges of training an international workforce.

Answered: 1 week ago