Add a toString method to the BankAccount class from the previous exercise. Your method should return a

Question:

Add a toString method to the BankAccount class from the previous exercise. Your method should return a string that contains the account’s name and balance separated by a comma and space. For example, if an account object named yana has the name "Yana" and a balance of 3.03, the call yana.toString() should return the string "Yana, $3.03".


Data from Previous Exercise

Suppose the following BankAccount class has been created:

1 // Each BankAccount object represents one user's account // information including name and balance of money. public class BankAccount { 4 String name; double balance; public void deposit (double amount) { 8 balance = balance + amount; 9. 10 11 public void withdraw (double amount) { 12 balance =

Add a field to the BankAccount class named transactionFee for a real number representing an amount of money to deduct every time the user withdraws money. The default value is $0.00, but the client can change the value. Deduct the transaction fee money during every withdraw call (but not from deposits). Make sure that the balance cannot go negative during a withdrawal. If the withdrawal (amount plus transaction fee) would cause it to become negative, don’t modify the balance at all.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: