Question: 13.3 Checking Account (Individual Assignment) Required Skills Inventory Write an derived class in Java according to Interface specifications given in UML. Implement base class Interfaces
13.3 Checking Account (Individual Assignment)
Required Skills Inventory
Write an derived class in Java according to Interface specifications given in UML.
Implement base class Interfaces in java according to specifications given in UML.
Problem Description and Given Info
You must write a public class named CheckingAccount with fields and methods as defined below, and that inherits from (extends) the BankAccount class.
UML CLass Diagram: CheckingAccount Inherits BankAccount
Structure of the Fields
As described by the UML Class Diagram above, your CheckingAccount class must have the following fields:
a private field named overdraftFee of type int initialized to 0
Structure of the Methods
As described by the UML Class Diagram above, your CheckingAccount class must have the following methods:
a public method named debit that takes an int argument and returns a boolean
a public method named setFee that takes an int and returns nothing
a public method named getFee that takes no arguments and returns an int
a public method named applyInterest that takes no arguments and returns nothing
a public method named accountInfo that takes no arguments and returns a String
Note that three of these methods are defined as abstract in the BankAccount base class. You will be overriding and implementing these methods in this CheckingAccount concrete derived class.
Behavior of the Methods
The debit method should subtract the argument amount from the balance. The debit method should always return true.
The setFee method should store the argument amount in the overdraftFee field.
The getFee method should return the value stored in the overdraftFee field.
The applyInterest method should compute the interest amount and add this amount to the balance, but only if the balance is greater than 0.
The accountInfo method will return a string formatted exactly like this:
Type of Account : Checking Account ID : 1111-2222-3333-4444 Current Balance : $123.45 Interest rate : 1.50% Overdraft Fee : $20.00
Additional Information
BankAccount Class
Copy and paste your BankAccount class code from your Bank Account (Individual Assignment) into the BankAccount.Java file in the editor below.
All Bank Accounts
All accounts have balance, credit and debit amounts, and fees stored and passed as a number of pennies (int).
All debit amounts will be subtracted from the balance, and all credit amounts will be added to the balance.
All bank accounts have a non-negative interest rate (0.02 would be a 2% interest rate).
When applying interest, interest amount is calculated by multiplying the balance by the interest rate.
When applying interest, interest amount is always added to the balance, and any fractional part will be rounded down.
Interest will not be applied to any Savings or Checking account with a balance of zero or less.
Debit methods will return false if the transaction cannot be made because of insufficient balance or insufficient credit limit. Otherwise they will return true.
The credit method will always return true.
Checking Accounts
A CheckingAccount can have a negative balance.
The debit method for the CheckingAccount will always return true.
Any CheckingAccount debit that ends with a negative balance will incur an overdraftFee (i.e. the overdraftFee amount will be subtracted from the balance). A CheckingAccount debit will always succeed.
Interest will not be applied to a CheckingAccountwith a negative balance.
public abstract class BankAccount { protected String accountID = "0000-0000-0000-0000";
protected double interestRate = 0;
protected int balance = 0;
public boolean credit(int pennies) { balance = balance + pennies; return true; }
public abstract boolean debit(int pennies);
public int getBalance() { return balance; }
public String getAccountID() { return accountID; }
public void setAccountID (String accountID) { this.accountID=accountID; }
public double getInterestRate() { return interestRate; }
public void setInterestRate(double interestRate) { this.interestRate = interestRate; }
public abstract void applyInterest();
public abstract String accountInfo(); }
please write code for CheckingAccount.java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
