Question: 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 OVERDRAFT_FEE =10; 1 usage
// Constructor with three arguments
public CheckingAccount(String accountHolderName, String accountNumber, int balance){7 usages new*
super(accountHolderName, accountNumber, balance); // Call superclass constructor
}
// Constructor with two arguments
public CheckingAccount(String accountHolderName, String accountNumber){7 usages new*
super(accountHolderName, accountNumber, balance: 0); // Initialize balance to zero
}
@Override 1 usage new *
public int withdraw(int amount){
int currentBalance = getBalance(); // Get the current balance
System.out.println("Current balance: "+ currentBalance);
int newBalance = currentBalance - amount; // Calculate the new balance after withdrawal
System.out.println("New balance after withdrawal: "+ newBalance);
// Check if the withdrawal amount exceeds the balance
if newBalance 0
// If the new balance is negative, apply the overdraft fee
newBalance -= OVERDRAFT_FEE
System.out.println("Applied overdraft fee. New balance after fee: "+ newBalance);
}
// Update the balance indirectly using the deposit method to ensure fee is applied
deposit( amountToDeposit: currentBalance - newBalance);
 package com.techelevator; public class CheckingAccount extends BankAccount { nousages new* private

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!