Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Current balance: 1 0 0 New balance after withdrawal: - 1 Applied overdraft fee. New balance after fee: - 1 1 Expected : : -

Current balance: 100
New balance after withdrawal: -1
Applied overdraft fee. New balance after fee: -11
Expected : :-11
Actual :211
>1> java bankaacount extends to checking account 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); get the right java solution
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions