Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and implement the following 3 classes with the exact fields and methods (

ID: 3866770 • Letter: D

Question

Design and implement the following 3 classes with the exact fields and methods (these names and caps exactly):

1. An abstract class named BankAccount (java file called BankAccount.java):

Balance A field for the bank account balance NumberDeposits A field for the number of deposits this month NumberWithdrawals A field for the number of withdrawals this month AnnualInterestRate A field for the annual interest rate MonthlyServiceCharge A field for the monthly service charge BankAccount A constructor method that accepts as arguments the balance and the annual interest rate SetMonthlyServiceCharges A method that accepts the monthly service charges as an argument and set the field value GetBalance A method that returns the bank account balance GetNumberDeposits A method that returns the number of deposits this month GetNumberWithdrawals A method that returns the number of withdrawals this month GetAnnualInterestRate A method that returns the annual interest rate GetMonthlyServiceCharge A method that returns the monthly service charge Deposit A method that accepts the amount of the deposit as an argument, add the value of that argument to the account balance, and increment the variable holding the number of deposits Withdrawal A method that accepts the amount of the withdrawal as an argument, subtracts that argument value from the balance, and increment the value holding the number of withdrawals CalculateInterest A method that updates the balance by calculating the monthly interest earned by the account ( MonthlyInterest = Balance * AnnualInterestRate/12 ), and adding this interest to the balance (Balance = Balance + MonthlyInterest) MonthlyProcess A method that subtracts the monthly service charges from the balance, callas the CalculateInterest method to calculate the interest, and then sets to 0 the variables for NumberDeposits, NumberWithdrawals, and MonthlyServiceCharge.

2. A class named SavingsAccount (java file called SavingsAccount.java) that extends the BankAccount class.

Status A private (Boolean) field that holds the account status: if it is active or inactive. If the balance of the account falls below $25, the account becomes inactive. No withdrawals can be made from an inactive account. SavingsAccount A constructor method that accepts as arguments the account balance, the annual interest rate, and the monthly service charge. The constructor should call the superclass constructor and, based on the account balance, the constructor should set the account Status to true or false. Deposit A method that accepts the deposit amount as an argument, calls the superclass version of the Deposit method to make a deposit, and then updates the Status of the accounts if the balance goes above $25. Withdrawal A method that accepts the withdrawal amount as an argument, checks if the status of the account is active, and, if that is true, calls the superclass version of the Withdrawal method, to make a withdrawal from the account. The method should update the Status if the balance goes under $25. MonthlyProcess A method that does the monthly process based on the number of withdrawals from the account: If the number of withdrawals for the month is less or equal to 4, the method calls the superclass version of the MonthlyProcess method, to do the monthly process. If the number of withdrawals for the month is more than 4, then a service charge of $1 for each withdrawal above 4 (e.g. $1 for 5, $2 for 6, etc.) is added to the superclass field that holds the monthly service charge (using the superclass SetMonthlyServiceCharges). Then, the method calls the superclass version of the MonthlyProcess method, to do the monthly process.

3. A driver class/program/project called [YourName]Assignment3 (java file called [YourName]Assignment3.java , replace [YourName] with your actual name) in the same project as the BankAccount.java and SavingsAccount.java that create one or more SavingsAccount objects and demonstrate the methods GetBalance, GetNumberDeposits, GetNumberWithdrawals, GetAnnualInterestRate, GetMonthlyServiceCharge, Deposit, Withdrawal, CalculateInterest, and MonthlyProcess for that particular SavingsAccount object.

Explanation / Answer

public abstract class BankAccount {

// A field for the bank account balance

private double Balance;

// A field for the number of deposits this month

private int NumberDeposits;

// A field for the number of withdrawals this month

private int NumberWithdrawals;

// A field for the annual interest rate

private double AnnualInterestRate;

// A field for the monthly service charge

private double MonthlyServiceCharge;

/**

* A constructor method that accepts as arguments the balance and the annual

* interest rate

*

* @param balance

* @param anualInterestRate

*/

public BankAccount(double balance, double anualInterestRate) {

// TODO Auto-generated constructor stub

this.Balance = balance;

this.AnnualInterestRate = anualInterestRate;

}

/**

* A method that accepts the monthly service charges as an argument and set

* the field value

*

* @param MonthlyServiceCharge

*/

public void SetMonthlyServiceCharges(double MonthlyServiceCharge) {

this.MonthlyServiceCharge = MonthlyServiceCharge;

}

/**

* A method that returns the bank account balance

*

* @return

*/

public double GetBalance() {

return this.Balance;

}

/**

* A method that returns the annual interest rate

*

* @return

*/

public double GetAnnualInterestRate() {

return this.AnnualInterestRate;

}

/**

* A method that returns the monthly service charge

*

* @return

*/

public double GetMonthlyServiceCharge() {

return this.MonthlyServiceCharge;

}

/**

* A method that accepts the amount of the deposit as an argument, add the

* value of that argument to the account balance, and increment the variable

* holding the number of deposits

*

* @param amount

*/

public void Deposit(double amount) {

this.Balance += amount;

this.NumberDeposits++;

}

/**

* A method that accepts the amount of the withdrawal as an argument,

* subtracts that argument value from the balance, and increment the value

* holding the number of withdrawals

*

* @param amount

*/

public void Withdrawl(double amount) {

this.Balance -= amount;

this.NumberWithdrawals++;

}

/**

* A method that returns the number of withdrawals this month

*

* @return

*/

public int GetNumberWithdrawals() {

return this.NumberWithdrawals;

}

/**

* method that returns the number of deposits this month

*

* @return

*/

public int GetNumberDeposits() {

return this.NumberDeposits;

}

public void CalculateInterest() {

double MonthlyInterest = Balance * AnnualInterestRate / 12;

this.Balance += MonthlyInterest;

}

public void MonthlyProcess() {

this.Balance -= MonthlyServiceCharge;

CalculateInterest();

NumberDeposits = NumberWithdrawals = 0;

MonthlyServiceCharge = 0.0;

}

}

public class SavingsAccount extends BankAccount {

// holds the account status: if it is active or inactive

private boolean Status;

/**

*

* @param balance

* @param anualInterestRate

*/

public SavingsAccount(double balance, double anualInterestRate,

double monthlyServiceCharge) {

super(balance, anualInterestRate);

// TODO Auto-generated constructor stub

SetMonthlyServiceCharges(monthlyServiceCharge);

if (balance < 25)

this.Status = false;

else

this.Status = true;

}

public void Deposit(double amount) {

super.Deposit(amount);

if (GetBalance() < 25)

this.Status = false;

else

this.Status = true;

}

public void Withdrawl(double amount) {

if (GetBalance() > 25)

super.Withdrawl(amount);

if (GetBalance() < 25)

this.Status = false;

else

this.Status = true;

}

public void MonthlyProcess() {

if (GetNumberWithdrawals() > 4) {

double charge = (4 - GetNumberWithdrawals());

super.SetMonthlyServiceCharges(charge);

super.MonthlyProcess();

}

}

}

public class MadhaviAssignment3 {

public static void main(String[] args) {

BankAccount account = new SavingsAccount(500, 0.2, 1);

System.out.println("Balance:" + account.GetBalance());

System.out.println("Transaction 1:");

account.Withdrawl(200);

System.out.println("After Withdrawl Balance:" + account.GetBalance());

System.out.println("After Withdrawl Number of withdrawls:"

+ account.GetNumberWithdrawals());

System.out.println("After Withdrawl Number of deposits:"

+ account.GetNumberDeposits());

System.out.println(" Transaction 2:");

account.Withdrawl(100);

System.out.println("After Withdrawl Balance:" + account.GetBalance());

System.out.println("After Withdrawl Number of withdrawls:"

+ account.GetNumberWithdrawals());

System.out.println("After Withdrawl Number of deposits:"

+ account.GetNumberDeposits());

System.out.println(" Transaction 3:");

account.Deposit(100);

System.out.println("After Deposit Balance:" + account.GetBalance());

System.out.println("After Deposit Number of withdrawls:"

+ account.GetNumberWithdrawals());

System.out.println("After Deposit Number of deposits:"

+ account.GetNumberDeposits());

}

}

OUTPUT:

Balance:500.0
Transaction 1:
After Withdrawl Balance:300.0
After Withdrawl Number of withdrawls:1
After Withdrawl Number of deposits:0

Transaction 2:
After Withdrawl Balance:200.0
After Withdrawl Number of withdrawls:2
After Withdrawl Number of deposits:0

Transaction 3:
After Deposit Balance:300.0
After Deposit Number of withdrawls:2
After Deposit Number of deposits:1

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote