Question: In Java, write some methods for a BankAccount class. A bank account has a customer name, a balance, and a count of transactions. The customer
In Java, write some methods for a BankAccount class. A bank account has a customer name, a balance, and a count of transactions. The customer can issue transactions to deposit and withdraw funds from an account. A customer can also issue a transaction to transfer funds from one account to another as long as they own both accounts.
Each method has been described in the starter file. Implement the class by adding instance fields and implementing the specified methods.
Start of Code:
A bank account class. Bank accounts have customer names,
balances, and transaction counts.
public class BankAccount
Constructs a bank account belonging to the customer
with the given initial balance. The initial balance
cannot be negative.
public BankAccountString customerName, double initialBalance
your code here
Returns a count of how many deposits, withdrawals,
and transfers were successful. Illegal transactions
should not be counted.
public int getTransactionCount
your code here;
return ;
Returns the name of the customer that owns this
account
public String getCustomerName
your code here
return null;
Returns the current balance of this account
public double getBalance
your code here
return ;
Deposits the amount into the account. Only nonzero,
positive deposit amounts are allowed. Successful
deposits increment the transaction count.
public void depositdouble amount
your code here
Withdraws the amount from the account. Only nonzero,
positive withdrawal amounts are allowed. Accounts
are not permitted to overdraft. Successful
withdrawals increment the transaction count.
public void withdrawdouble amount
your code here
Transfers the amount from this account to the destination
account. This is only valid if the same person owns both
accounts. Further, only nonzero, positive amounts are
allowed. Accounts are not permitted to overdraft.
Successful transfers increment the transaction
count in both accounts.
public void transferBankAccount destination, double amount
your code here
Produce a string containing the details of this account. Assertions
a minimum, the string should contain the account holder name,
the balance, and the transaction count.
public String toString
your code here
return null;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
