Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Update BankAccount class to: Add an instance of the Customer class to your BankAccount class as an instance variable with a getter and setter method.

Update BankAccount class to:

Add an instance of the Customer class to your BankAccount class as an instance variable with a getter and setter method. The name of the instance variable should be accountHolder.

Add appropriate constructors to allow creation of bank accounts to specify an account holder.

Update the toString method such that the string returned includes account holder information.

Add a method called transfer that takes an amount to transfer and an account to transfer to as arguments. The transfer should only take place if the account has enough funds.

That's my bankAcount code. no prompt for user imput

public class BankAccount{ private double balance; private String accountNumber;

public BankAccount(){ this.balance = 0.0; this.accountNumber = "0001"; }

public BankAccount(double balance){ this.balance = balance; this.accountNumber = "0001"; }

public BankAccount(double balanceToStart, String accountNumberToStart){ this.balance = balanceToStart; this.accountNumber = accountNumberToStart; }

public double getBalance(){ return this.balance; }

public String getAccountNumber(){ return this.accountNumber; }

public String toString(){ return this.getAccountNumber() + ": " + this.getBalance(); }

public void deposit(double amount){ if(amount >= 0) { double check = this.balance + amount; this.balance = check; } }

public void withdraw(double amount){ if(amount >= 0 && this.balance >= amount) { this.balance = this.balance - amount; } }

}

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

More Books

Students also viewed these Databases questions

Question

When is an employer liable for the actions of an employee?

Answered: 1 week ago