Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class BankAccount { private String owner; private double balance; public BankAccount ( String holderName, double originalBalance ) { owner = holderName; balance = originalBalance;

public class BankAccount {
private String owner;
private double balance;
public BankAccount(String holderName, double originalBalance){
owner = holderName;
balance = originalBalance;
}
public void deposit(double amount){
if (amount >=0){
balance += amount;
System.out.println("You have deposited: "+ amount);
}
}
public void withdrawal(double amount){
if (amount >0 && balance >= amount){
balance -= amount;
System.out.println("You have withdrawn: "+ amount);
}
}
public String getOwner(){
return owner;
}
public double getBalance(){
return balance;
}
} public class CheckingAccount extends BankAccount {
private double insufficientFundPenalty;
public CheckingAccount(String holderName, double originalBalance, double insufficientFundPenalty){
super(holderName, originalBalance);
this.insufficientFundPenalty = insufficientFundPenalty;
}
@Override
public void withdrawal(double amount){
if (amount >0){
if (getBalance()>= amount){
super.withdrawal(amount);
} else {
System.out.println("You don't have enough money, withdrawing all available funds and applying insufficient funds.");
super.withdrawal(getBalance());
amount-=getBalance();
insufficientFundPenalty-=amount;
}
}
}
public double getInsufficientFundPenalty(){
return insufficientFundPenalty;
}
public void checkProcess(double amount){
System.out.println("Attempting to withdraw: "+ amount);
withdrawal(amount);
System.out.println("Balance after withdrawal attempt: "+ getBalance());
System.out.println("The insufficient fund penalty available: "+ getInsufficientFundPenalty());
}
} Im trying to create a checkingaccount class for bankaccount class,It suppose to withdraw all of user's money in account first, then starting withdraw the penaltyfund I set, but it not working

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

Step: 3

blur-text-image

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

User Defined Tensor Data Analysis

Authors: Bin Dong ,Kesheng Wu ,Suren Byna

1st Edition

3030707490, 978-3030707491

More Books

Students also viewed these Databases questions

Question

Discuss the key people management challenges that Dorian faced.

Answered: 1 week ago

Question

How fast should bidder managers move into the target?

Answered: 1 week ago