Answered step by step
Verified Expert Solution
Question
1 Approved Answer
package com.techelevator; public class CheckingAccount extends BankAccount { nousages new * private static final int OVERDRAFT _ FEE = 1 0 ; 1 usage /
package com.techelevator;
public class CheckingAccount extends BankAccount nousages new
private static final int OVERDRAFTFEE ; usage
Constructor with three arguments
public CheckingAccountString accountHolderName, String accountNumber, int balance usages new
superaccountHolderName accountNumber, balance; Call superclass constructor
Constructor with two arguments
public CheckingAccountString accountHolderName, String accountNumber usages new
superaccountHolderName accountNumber, balance: ; Initialize balance to zero
@Override usage new
public int withdrawint amount
int currentBalance getBalance; Get the current balance
System.out.printlnCurrent balance: currentBalance;
int newBalance currentBalance amount; Calculate the new balance after withdrawal
System.out.printlnNew balance after withdrawal: newBalance;
Check if the withdrawal amount exceeds the balance
if newBalance
If the new balance is negative, apply the overdraft fee
newBalance OVERDRAFTFEE
System.out.printlnApplied overdraft fee. New balance after fee: newBalance;
Update the balance indirectly using the deposit method to ensure fee is applied
deposit amountToDeposit: currentBalance newBalance;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started