Design an abstract class named BankAcccount to hold the following data for a ban
ID: 3529888 • Letter: D
Question
Design an abstract class named BankAcccount to hold the following data for a bank account: -Account Name & Number -Balance -Number of deposits -Number of withdrawals -Annual interest rate -Monthly service charges The class should have the following methods: Constructor: The constructor should accept arguments for the balance and annual interest rate. deposit: A method that accepts an argument for the amount of the deposit. The method should add the argument for the amount of the deposit. The method should add the argument to the account balance. It should also increment the variable holding the number of deposits. withdraw: A method that accepts an argument for the amount of the withdrawal. The method should subtract the argument from the balance. It should also increment the variable holding the number of withdrawals. calcInterest: A method that updates the balance by calculating the monthly interest earned by the account, and adding this interest to the balance. This is performed according to the following formulas: Monthly InterestRate = (Annual Interest Rate / 12) Monthly Interest = Balance *Monthly Interest Rate Balance = Balance + MonthlyInterest monthlyProcess: A method that subtracts the monthly service charge from the balance, calls the calc Interest method, and then sets the variables that hold the number of withdrawals, number of deposits, and monthly service charges to zero. Next, design a SavingsAccount class that extends the BankAccount class.The SavingsAccount class should have a status field to represent an active or inactive account. If the balance of a savings account falls below $25, it becomes inactive. (The status field could be a boolean variable.) No more withdrawals may be made until the balance is raised above $25, at which time the account becomes active again. The savingsaccount class should have the following methods: withdraw: A method that determines whether the account is inactive before a withdrawal is made. ) No withdrawal will be allowed if the account is not active.) A withdrawal is then made by calling the superclass version of the method (assuming it is allowed). deposit: A method that determines whether the account is inactive before a deposit is made. If the account is inactive and the deposit brings the balance above $25, the account becomes active again. A deposit is then made by calling the superclass version of the method. monthlyProcess: Beforethe superclass method is called, this method checks the number of withdrawals. If the number of withdrawals for the month is more than 4, a service charge of $1 for each withdrawal above 4 is added to the superclass field that holds the monthly service charges.(DonExplanation / Answer
public class BankAccount { //declase class fields private double balance; private double deposit; private double withdrawal; private double annualRate; private double monthlyFee; private double monthlyInterest; //constructor public BankAccount(double myBalance, double myAnnualRate) { //initiliaze class fields balance = myBalance; annualRate = myAnnualRate; deposit = 0; withdrawal = 0; monthlyFee = 0; } //class methods public double getBalance() { return balance; } public void setBalance(double myBalance) { balance = myBalance; } public double getDeposit() { return deposit; } public void setDeposits(double myDeposit) { balance = myDeposit; deposit += 1; } public double getWithdrawal() { return withdrawal; } public void setWithdrawal(double myAmount) { double amount = myAmount; balance = balance - myAmount; withdrawal += 1; } public double getAnnualRate() { return annualRate; } public double calcInterest() { double monthlyRate; monthlyRate = (annualRate/12); monthlyInterest = balance * monthlyInterest; balance = balance + monthlyRate; return balance; } public String getMonthlyProcess() { calcInterest(); withdrawal = 0; deposit = 0; monthlyFee = 0; return "Monthly Process: " + balance; } } public class SavingsAccount extends BankAccount { public int minAmount; private double minAmout; private int numberOfWithdrawals; public boolean withdraw(double amount) { if (getBalance() >= amount + minAmount) { super.withdraw(amount); return true; } else return false; } public SavingsAccount() { balance = 0; numberOfwithdrawals = 0; } public void withdraw (int amount) { double tempBalance; tempBalance = balance - withdrawMoney; //checks to make sure you have enough money before calculations are done if (tempBalance < 25) { System.out.println ("Insufficient funds! You only have $" + balance + " dollars" ); } else { balance -= withdrawMoney; } } public void resetNumOfWithdrawals () { } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.