Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Code should be in java Specific Instructions: Do the following problem from Exer

ID: 3847559 • Letter: C

Question

Code should be in java

Specific Instructions:
Do the following problem from Exercises at the end of Chapter 8 of the text. Chapter 8: Exercises #11, #12, and #13, Building Java Programs(I will attatch photo of exercise description).

You are to incorporate all requirements of the three exercises into the basic classdefinition provided in the Exercise #11 description. In addition, you must check thevalues of deposit, withdrawal, and transfer amounts to ensure they are greater than 0. For two of the three methods, deposit and withdraw, the methods are to return a booleanvalue to indicate if the transaction was completed. For method transfer, the method is toRETurn the allowed amount transferred, refer to Exercise #13 for details for a partialtransfer. In addition to the specified class methods, provide a method name() that returns a String reference to the object’s account name.

To start this project, create an Eclipse project and copy the two supplied source codefiles, Project9_BankAccount.java and BankAccount.java into the project’s src folder. FileBankAccount.java has the class definition shown in the text as your starting point; notethat methods deposit and withdraw are incomplete! You must define all requiredmethods in this file. You should not modify the Project9_BankAccount.java file as itprovides a means to test your code. I will utilize this same test program to verify thefunctionality of the BankAccount class source code file you submit. Your code mustwork as shown with my “test” program! A sample Console output from this program isshown below. Code method toString() to produce the output shown for the class objectsin the following Sample Console Output.

Skeleton of project, BankAccount.java

public class BankAccount
{
   // Public Interface
   // 1. Constructors
//   Add your Constructor(s) here......

  
   // 2. Mutator Methods
   // A. boolean deposit(double)
   // Note: This method enforces the class invariant that stipulates
   // that a deposit amount MUST be > $0.00
   public boolean deposit(double depositAmount)
   {
       boolean depositMade = false;
      
// Insert your code here. Remember, you MUST enforce the invariant condition!!!      
      
       return depositMade;
   }
   //
   // B. boolean withdraw(double)
   // Note: This method enforces the class invariant that stipulates
   // that the ending account balance MUST be >= $0.00
   public boolean withdraw(double withdrawalAmount)
   {
       boolean withdrawalMade = false;
      
//       Insert your code here. Remember, you MUST enforce the invariant condition!!!      
      
       return withdrawalMade;
   }
   //
   // C. double transfer(BankAccount,double)
   // RETurns the amount transferred: 0.0 - No transfer occurred
   public double transfer(double withdrawalAmount)
   {
       double amountTransfered = 0.0;
      
// Create your method here

       return amountTransfered;
   }
   //
   //
   // 3. Virtual (late binding) Methods: Extensions of class "Object"
   // A. toString()
// Constructs Description "String" of the object
   String toString()
   {
       String str = "";
      
//    Insert your code here.....
      
       return str;
   }

   // Class Private, non-static Data Members
   // Private Class Data Members
   // 1. Variable Declarations
   private String name;
   private double balance;

}   // End Class Definition: BankAccount

file to test program, Project9_BankAccount.java

public class Project9_BankAccount
{  
   /**************************************************************************
   * Method: main(String[])
   *
   * Method Description
   * ------------------
   * This static method is the entry point to the program.
   *
   * The program tests the class "BankAccount", which allows for deposits and
   * withdrawals from a "BankAccount" object. The class, "BankAccount",
   * supports three initializing Constructors, one that takes the name of the
   * account only, one that takes the name and the beginning balance, and the
   * third that takes the name, beginning balance, and the withdrawal
   * transaction fee. Three objects will be defined to test all three allowed
   * Constructors. In addition, deposits and withdrawals will be performed to
   * verify the arithmetic.
   *
   *
   * Pre-Conditions
   * --------------
   * None
   *
   *
   * ------------------------------- Arguments ------------------------------
   * Type Name Description
   * -------- ---- --------------------------------------------------------
   * String[] args Array of "String" argument(s) passed to main() when the
   * Console program is invoked by the User.
   *
   *
   * RETurn
   * Type Description
   * ------ ----------------------------------------------------------------
   * void The method RETurns no value
   *
   *
   * Invoked Methods
   * ---------------
   * Name Description
   * -------------- --------------------------------------------------------
   * introduction Inform User of the Project solution
   * makeDeposit Add deposit to referenced "BankAccount"
   * makeWithdrawal Withdrawal from referenced "BankAccount"
   * transfer Transfer amount from one account to another account
   *
   **************************************************************************
   */
   public static void main(String[] args)
   {
// Constant "final" Value Declarations
final double BEGINNING_BALANCE1 = 23.67;
final double BEGINNING_BALANCE2 = 34.57;
final double TRANSACTION_FEE = 2.50;
  
       // Create a "BankAccount" object, specifying just the account holder's
       // name. The beginning balance and withdrawal fee will be set to $0.0.
BankAccount myAccount = new BankAccount("John Doe");
  
// Create arrays of deposit, withdrawal, and transfer amounts.
double[] deposits = new double[] { 51.75, 14.78, -4.59 };
double[] withdrawals = new double[] { 7.96, 45.79, -3.57, 12.78, .01, 75.86 };
double[] transfers = new double[] { 41.38, -8.79, 78.67, 94.74, .01, 150.00 };
  
// Uninitialized Variable Declarations
double deposit, withdrawal, transfer;

  
// Inform the User of the Project Solution
introduction();
  
// Example #1: Account name only specified to Constructor
System.out.println(" Example #1: Account object instantiated with name only");
// Display the beginning account balance
System.out.println(" Beginning account:" +
               " " + myAccount);
  
// Make a deposit to the account object, then "display" the object
// via the overloaded "toString()" class method.
deposit = deposits[0];
System.out.println(" Depositing: $" + deposit);
makeDeposit(myAccount, deposit);
  
// Now make a withdrawal
withdrawal = withdrawals[0];
System.out.println(" Withdrawing: $" + withdrawal);
makeWithdrawal(myAccount, withdrawal);
  
// Then another deposit
deposit = deposits[1];
System.out.println(" Depositing: $" + deposit);
makeDeposit(myAccount, deposit);
  
// Then another deposit that is a negative value
deposit = deposits[2];
System.out.println(" Depositing: $" + deposit);
makeDeposit(myAccount, deposit);
  
// Another withdrawal
withdrawal = withdrawals[1];
System.out.println(" Withdrawing: $" + withdrawal);
makeWithdrawal(myAccount, withdrawal);
  
// Another withdrawal that is a negative value
withdrawal = withdrawals[2];
System.out.println(" Withdrawing: $" + withdrawal);
makeWithdrawal(myAccount, withdrawal);
  
// Another withdrawal that will result in a balance of $0.00.
withdrawal = withdrawals[3];
System.out.println(" Withdrawing: $" + withdrawal);
makeWithdrawal(myAccount, withdrawal);
  
// Finally, a withdrawal the will exceed the current account balance
withdrawal = withdrawals[4];
System.out.println(" Withdrawing: $" + withdrawal);
makeWithdrawal(myAccount, withdrawal);


// Example #2: Account name and beginning balance specified to the Constructor
System.out.println(" Example #2: Account object instantiated with name and" +
               " beginning balance: $" + BEGINNING_BALANCE1);
       // Create a "BankAccount" object, specifying the account holder's name
       // and beginning balance. The withdrawal fee will be set to $0.00.
// Note: This is an example of the Java feature of "garbage" collection.
// The REFERENCE "account" is assigned to a new "BankAccount" class
// object. Java will detect that no other reference refers to the
// previous object (Name: John Doe) and will automatically return
// the memory allocated for that object to the Heap Memory Manager.
myAccount = new BankAccount("Sarah Jones", BEGINNING_BALANCE1);
// Display the beginning account balance
System.out.println(" Beginning account:" +
               " " + myAccount);
  
// Make a deposit to the account object, then "display" the object
// via the overloaded "toString()" class method.
deposit = deposits[0];
System.out.println(" Depositing: $" + deposit);
makeDeposit(myAccount, deposit);
  
// Now make a withdrawal
withdrawal = withdrawals[0];
System.out.println(" Withdrawing: $" + withdrawal);
makeWithdrawal(myAccount, withdrawal);


// Example #3: Account name, beginning balance, and transaction fee are
// specified to the Constructor
System.out.println(" Example #3: Account object instantiated with name," +
               " beginning balance: $" + BEGINNING_BALANCE2 +
               ", and transaction fee: $" + String.format("%.2f", TRANSACTION_FEE));
       // Create a "BankAccount" object, specifying the account holder's name,
       // the beginning balance, and the transaction fee.
BankAccount yourAccount =
       new BankAccount("Samuel Johnson", BEGINNING_BALANCE2, TRANSACTION_FEE);
// Display the beginning account balance
System.out.println(" Beginning account:" +
               " " + yourAccount);
  
// Make a deposit to the account object, then "display" the object
// via the overloaded "toString()" class method.
deposit = deposits[0];
System.out.println(" Depositing: $" + deposit);
makeDeposit(yourAccount, deposit);
  
// Now make a withdrawal
withdrawal = withdrawals[0];
System.out.println(" Withdrawing: $" + withdrawal);
makeWithdrawal(yourAccount, withdrawal);
  
// Now make a withdrawal of the exact remaining balance
// Note: The fee + withdrawal will exceed the remaining balance!
withdrawal = withdrawals[5];
System.out.println(" Withdrawing: $" + withdrawal);
makeWithdrawal(yourAccount, withdrawal);


// Example #4: Transfer between accounts
System.out.println(" Example #4: Transfers between two accounts");
System.out.println( " myAccount: " + myAccount +
               " yourAccount: " + yourAccount);
// Make a valid transfer from "myAccount" to "yourAccount"
transfer = transfers[0];
System.out.println(" Transfering $" + transfer + " from " + myAccount.name() +
       "'s account to " + yourAccount.name() + "'s account");
transfer(myAccount, yourAccount, transfer);
  
// Make an invalid transfer (negative amount) from "myAccount" to "yourAccount"
transfer = transfers[1];
System.out.println(" Transfering $" + transfer + " from " + myAccount.name() +
       "'s account to " + yourAccount.name() + "'s account");
transfer(myAccount, yourAccount, transfer);
  
// Make a valid transfer from "yourAccount" to "myAccount"
transfer = transfers[2];
System.out.println(" Transfering $" + transfer + " from " + yourAccount.name() +
       "'s account to " + myAccount.name() + "'s account");
transfer(yourAccount, myAccount, transfer);
  
// Make a second valid transfer from "yourAccount" to "myAccount" that results
// in a balance of $0.01 in "myAccount"
transfer = transfers[3];
System.out.println(" Transfering $" + transfer + " from " + myAccount.name() +
       "'s account to " + yourAccount.name() + "'s account");
transfer(myAccount, yourAccount, transfer);
  
// Make an invalid transfer (insufficient funds) from "myAccount" to "yourAccount"
transfer = transfers[4];
System.out.println(" Transfering $" + transfer + " from " + myAccount.name() +
       "'s account to " + yourAccount.name() + "'s account");
transfer(myAccount, yourAccount, transfer);
  
// Make an invalid transfer (insufficient funds) from "yourAccount" to "myAccount"
transfer = transfers[5];
System.out.println(" Transfering $" + transfer + " from " + yourAccount.name() +
       "'s account to " + myAccount.name() + "'s account");
transfer(yourAccount, myAccount, transfer);
  
   } // End static method: main(String[])
  
  
   /**************************************************************************
   * Method: introduction()
   *
   * Method Description
   * ------------------
   * This static method describes the Project solution to the User.
   *
   *
   * Pre-Conditions
   * --------------
   * None
   *
   *
   * ------------------------------- Arguments ------------------------------
   * *** No Arguments supplied ***
   *
   *
   * RETurn
   * Type Description
   * ------ ----------------------------------------------------------------
   * void The method RETurns no value
   *
   *
   * Invoked Methods
   * ---------------
   * None
   *
   **************************************************************************
   */
   private static void introduction()
   {
       System.out.println(" Project #8 Solution" +
                       " Chapter 8, Exercise #11, page 568 ");
   }
  
  
   /**************************************************************************
   * Method: makeDeposit(BankAccount,double)
   *
   * Method Description
   * ------------------
   * This static method deposits the amount specified (argument) into the
   * specified (reference argument) "BankAccount" object. After the deposit,
   * the account is displayed by calling, indirectly, the overloaded
   * "toString()" class method.
   *
   *
   * Pre-Conditions
   * --------------
   * 1. The "account" reference is not "null"
   *
   *
   * RETurn
   * Type
   * ------
   * None
   *
   * ------------------------------- Arguments ------------------------------
   * Type Name Description
   * ------------ -------- ------------------------------------------------
   * BankAccount account Reference to a "BankAccount" object
   * double deposit Amount of the deposit
   *
   *
   * RETurn
   * Type Description
   * ------ ----------------------------------------------------------------
   * void The method RETurns no value
   *
   *
   * Invoked Methods
   * ---------------
   * None
   *
   **************************************************************************
   */
   private static void makeDeposit(BankAccount account, double deposit)
   {
       // First, attempt to make the deposit
if (account.deposit(deposit) )
{   // A deposit amount >0 was specified, continue...
   // Now "display" the object to the User. By specifying the REFERENCE
   // to the object as an argument in the "println" method, the compiler
   // will generate a call to the overloaded class method, "toString()".
   System.out.println(" " + account);
}
else
{   // Otherwise, an invalid deposit amount was specified
   System.out.println(" Unable to deposit $" +
       String.format("%.2f", deposit));
}
   }
  
  
   /**************************************************************************
   * Method: makeWithdrawal(BankAccount,double)
   *
   * Method Description
   * ------------------
   * This static method deposits the amount specified (argument) into the
   * specified (reference argument) "BankAccount" object. After the deposit,
   * the account is displayed by calling, indirectly, the overloaded
   * "toString()" class method.
   *
   *
   * Pre-Conditions
   * --------------
   * 1. The "account" reference is not "null"
   *
   *
   * ------------------------------- Arguments ------------------------------
   * Type Name Description
   * ------------ ---------- ----------------------------------------------
   * BankAccount account Reference to a "BankAccount" object
   * double withdrawal Amount of the withdrawal
   *
   *
   * RETurn
   * Type Description
   * ------ ----------------------------------------------------------------
   * void The method RETurns no value
   *
   *
   * Invoked Methods
   * ---------------
   * None
   *
   **************************************************************************
   */
   private static void makeWithdrawal(BankAccount account, double withdrawal)
   {
       // Attempt to make the withdrawal. The class method, "withdrawal" will
       // RETurn a "boolean" value; "true": Withdrawal made,
       // "false": Withdrawal (+ fee, if applicable) will exceed current
       // balance.
       boolean status = account.withdraw(withdrawal);
      
       if (status)
       {   // Withdrawal was successful, display the remaining balance.
   System.out.println(" " + account);
       }
else
{   // Otherwise, inform the User that withdrawal was NOT made.
   System.out.println(" Unable to withdraw $" +
       String.format("%.2f", withdrawal));
}
      
       // Note: A "return" statement is unnecessary for a method that "returns"
       // "void", but is allowed for completeness.
       return;
   }
  
  
   /**************************************************************************
   * Method: transfer(BankAccount,BankAccount,double)
   *
   * Method Description
   * ------------------
   * This static method attempts to withdraw the secified amount from the
   * "source", "BankAccount" object, and if possible, deposits that amount
   * or part thereof, to the "destination", "BankAccount" object.
   * The trasfer is accomplished by invoking the "source" object's non-
   * static data member, "transfer", which RETurns a "bool" value, "true",
   * the transfer occurred.
   *
   *
   * Pre-Conditions
   * --------------
   * 1. The "account" reference is not "null"
   *
   *
   * ------------------------------- Arguments ------------------------------
   * Type Name Description
   * ------------ ------------ --------------------------------------------
   * BankAccount source Reference to the source "BankAccount" object
   * BankAccount destination Reference to the destination object
   * double withdrawal Amount of the withdrawal
   *
   *
   * RETurn
   * Type Description
   * ------ ----------------------------------------------------------------
   * void The method RETurns no value
   *
   *
   * Invoked Methods
   * ---------------
   * None
   *
   **************************************************************************
   */
   private static void transfer(BankAccount source, BankAccount destination,
                               double transferAmount)
   {
       // Attempt to make the transfer. The class method, "transfer" will
       // RETurn a "boolean" value; "true": Transfer was made,
       // "false": Transfer + fee will exceed current balance of the
       // source account.
       double amountTransferred = source.transfer(destination, transferAmount);
      
       if (amountTransferred > 0.0)
       {   // Transfer was successful, display the two accounts.
   System.out.printf(" Source Account: %s" +
                   " Amount Transferred: %.2f" +
                         " Destination Account: %s ",
                         source, amountTransferred, destination);
       }
else
{   // Otherwise, inform the User that withdrawal was NOT made.
   System.out.println(" Unable to transfer $" +
       String.format("%.2f", transferAmount));
}
   }
  
} // End class definition: Project9_BankAccount

Other things to consider

1. You must design your "BankAccount" class such that it will satisfy the requirements stated in the three text problems. The supplied Client program will invoke the required class, non-static methods described in the text and in the Project Description document (Note the additional, required method, "name()".

2. The supplied Client program creates 3 different "BankAccount" objects. You should notice that each takes different number of arguments. Therefore, you will need to supply at least 3 Constructors for the class. You are to make sure that proper values are passed to the Constructors you define, i.e. the starting balance and transaction fee must be greater than or equal to 0.0. Also note that unless supplied in a Constructor, the transaction fee is set to the specified "default" value of 0.0....hint a Class static constant (final) value.

3. For Class method "deposit" you must enforce the invariant condition that a deposit amount must be greater than 0.0. The same goes for a withdrawal and transfer amount supplied to methods "withdraw" and "transfer".

4. For a "withdraw", the transaction can be completed iff (if and only if) the specified withdraw amount PLUS the transaction fee is >= the current balance.

5. You are to keep an accumulated total of all fees charged to the account; i.e. update this amount each time the "withdraw" and "transfer" methods are called.

6. For a transfer, there is fixed, constant fee of $5.00. Note that this is a different fee than the transaction fee that applies to a withdrawal. The transfer can only occur if the current balance of the invoking "BankAccount" object exceeds $5.00. If the account balance exceeds $5.00 but is less than the requested transfer amount plus the $5.00 fee, a partial transfer can occur that leaves the invoking object's balance as exactly $0.00. Only the allowed transfer amount is "deposit"ed to the target account, the "BankAccount" object reference passed to the "transfer" method.

7. You will need to provide an overridden "toString()" method as specified in Exercise #12. In addition to the format specified in the exercise, you are to include the total accumulated fees charged, see my sample output.

8. You are free to use class private "helper" method(s) to implement your method designs. A good example would be methods(s) to enforce the invariant conditions.

Thank you in advance! I will be sure to rate!

Explanation / Answer

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ BankAccount Class ////////////////////////////////////////////////////////////////

public class BankAccount
{
   // Class Private, non-static Data Members
    // Private Class Data Members
    // 1. Variable Declarations
   private String myname;
   private double balance;
  
   // Public Interfaces
   // 1. Constructors
   public BankAccount(String name,double bal) {
       this.myname = name;
       this.balance = bal;
   }
   public BankAccount(String name,double bal,double transFee) {
       this.myname = name;
       this.balance = bal;
       this.balance -=transFee;
   }
   public BankAccount(String name) {
       this.myname = name;
       this.balance = 0.0d;
   }

   // 2. Mutator Methods
   // A. boolean deposit(double)
   // Note: This method enforces the class invariant that stipulates
   // that a deposit amount MUST be > $0.00
   public boolean deposit(double depositAmount)
   {
       boolean depositMade = false;
       if(depositAmount>0.0d){
           balance += depositAmount;
           depositMade = true;
       }
       return depositMade;
   }
  
   // B. boolean withdraw(double)
   // Note: This method enforces the class invariant that stipulates
   // that the ending account balance MUST be >= $0.00
   public boolean withdraw(double withdrawalAmount)
   {
       boolean withdrawalMade = false;
       if(withdrawalAmount>0.0d && balance >= withdrawalAmount){
           balance -= withdrawalAmount;
           withdrawalMade = true;
       }
       return withdrawalMade;
   }

   // C. double transfer(BankAccount,double)
   // RETurns the amount transferred: 0.0 - No transfer occurred
   public double transfer(BankAccount ac, double transferAmount)
   {
       double amountTransfered = 0.0;
       if(withdraw(transferAmount)){
           ac.deposit(transferAmount);
           amountTransfered = transferAmount;
       }
       return amountTransfered;
   }

   // 3. Virtual (late binding) Methods: Extensions of class "Object"
   // A. toString()
   // Constructs Description "String" of the object
   public String toString()
   {
       String str = "Name : "+myname+" Balance : "+balance+" ";
       return str;
   }

   public String name(){
       return myname;
   }
}


\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\End of BankAccount Class////////////////////////////////////////////////////////////////

public class Project9_BankAccount
{
   /**************************************************************************
   * Method: main(String[])
   *
   * Method Description
   * ------------------
   * This static method is the entry point to the program.
   *
   * The program tests the class "BankAccount", which allows for deposits and
   * withdrawals from a "BankAccount" object. The class, "BankAccount",
   * supports three initializing Constructors, one that takes the name of the
   * account only, one that takes the name and the beginning balance, and the
   * third that takes the name, beginning balance, and the withdrawal
   * transaction fee. Three objects will be defined to test all three allowed
   * Constructors. In addition, deposits and withdrawals will be performed to
   * verify the arithmetic.
   *
   *
   * Pre-Conditions
   * --------------
   * None
   *
   *
   * ------------------------------- Arguments ------------------------------
   * Type Name Description
   * -------- ---- --------------------------------------------------------
   * String[] args Array of "String" argument(s) passed to main() when the
   * Console program is invoked by the User.
   *
   *
   * RETurn
   * Type Description
   * ------ ----------------------------------------------------------------
   * void The method RETurns no value
   *
   *
   * Invoked Methods
   * ---------------
   * Name Description
   * -------------- --------------------------------------------------------
   * introduction Inform User of the Project solution
   * makeDeposit Add deposit to referenced "BankAccount"
   * makeWithdrawal Withdrawal from referenced "BankAccount"
   * transfer Transfer amount from one account to another account
   *
   **************************************************************************
   */
   public static void main(String[] args)
   {
       // Constant "final" Value Declarations
       final double BEGINNING_BALANCE1 = 23.67;
       final double BEGINNING_BALANCE2 = 34.57;
       final double TRANSACTION_FEE = 2.50;
      
               // Create a "BankAccount" object, specifying just the account holder's
               // name. The beginning balance and withdrawal fee will be set to $0.0.
       BankAccount myAccount = new BankAccount("John Doe");
      
       // Create arrays of deposit, withdrawal, and transfer amounts.
       double[] deposits = new double[] { 51.75, 14.78, -4.59 };
       double[] withdrawals = new double[] { 7.96, 45.79, -3.57, 12.78, .01, 75.86 };
       double[] transfers = new double[] { 41.38, -8.79, 78.67, 94.74, .01, 150.00 };
      
       // Uninitialized Variable Declarations
       double deposit, withdrawal, transfer;
      
      
       // Inform the User of the Project Solution
       introduction();
      
       // Example #1: Account name only specified to Constructor
       System.out.println(" Example #1: Account object instantiated with name only");
       // Display the beginning account balance
       System.out.println(" Beginning account:" +
                       " " + myAccount);
      
       // Make a deposit to the account object, then "display" the object
       // via the overloaded "toString()" class method.
       deposit = deposits[0];
       System.out.println(" Depositing: $" + deposit);
       makeDeposit(myAccount, deposit);
      
       // Now make a withdrawal
       withdrawal = withdrawals[0];
       System.out.println(" Withdrawing: $" + withdrawal);
       makeWithdrawal(myAccount, withdrawal);
      
       // Then another deposit
       deposit = deposits[1];
       System.out.println(" Depositing: $" + deposit);
       makeDeposit(myAccount, deposit);
      
       // Then another deposit that is a negative value
       deposit = deposits[2];
       System.out.println(" Depositing: $" + deposit);
       makeDeposit(myAccount, deposit);
      
       // Another withdrawal
       withdrawal = withdrawals[1];
       System.out.println(" Withdrawing: $" + withdrawal);
       makeWithdrawal(myAccount, withdrawal);
      
       // Another withdrawal that is a negative value
       withdrawal = withdrawals[2];
       System.out.println(" Withdrawing: $" + withdrawal);
       makeWithdrawal(myAccount, withdrawal);
      
       // Another withdrawal that will result in a balance of $0.00.
       withdrawal = withdrawals[3];
       System.out.println(" Withdrawing: $" + withdrawal);
       makeWithdrawal(myAccount, withdrawal);
      
       // Finally, a withdrawal the will exceed the current account balance
       withdrawal = withdrawals[4];
       System.out.println(" Withdrawing: $" + withdrawal);
       makeWithdrawal(myAccount, withdrawal);
      
      
       // Example #2: Account name and beginning balance specified to the Constructor
       System.out.println(" Example #2: Account object instantiated with name and" +
                       " beginning balance: $" + BEGINNING_BALANCE1);
               // Create a "BankAccount" object, specifying the account holder's name
               // and beginning balance. The withdrawal fee will be set to $0.00.
       // Note: This is an example of the Java feature of "garbage" collection.
       // The REFERENCE "account" is assigned to a new "BankAccount" class
       // object. Java will detect that no other reference refers to the
       // previous object (Name: John Doe) and will automatically return
       // the memory allocated for that object to the Heap Memory Manager.
       myAccount = new BankAccount("Sarah Jones", BEGINNING_BALANCE1);
       // Display the beginning account balance
       System.out.println(" Beginning account:" +
                       " " + myAccount);
      
       // Make a deposit to the account object, then "display" the object
       // via the overloaded "toString()" class method.
       deposit = deposits[0];
       System.out.println(" Depositing: $" + deposit);
       makeDeposit(myAccount, deposit);
      
       // Now make a withdrawal
       withdrawal = withdrawals[0];
       System.out.println(" Withdrawing: $" + withdrawal);
       makeWithdrawal(myAccount, withdrawal);
      
      
       // Example #3: Account name, beginning balance, and transaction fee are
       // specified to the Constructor
       System.out.println(" Example #3: Account object instantiated with name," +
                       " beginning balance: $" + BEGINNING_BALANCE2 +
                       ", and transaction fee: $" + String.format("%.2f", TRANSACTION_FEE));
               // Create a "BankAccount" object, specifying the account holder's name,
               // the beginning balance, and the transaction fee.
       BankAccount yourAccount =
               new BankAccount("Samuel Johnson", BEGINNING_BALANCE2, TRANSACTION_FEE);
       // Display the beginning account balance
       System.out.println(" Beginning account:" +
                       " " + yourAccount);
      
       // Make a deposit to the account object, then "display" the object
       // via the overloaded "toString()" class method.
       deposit = deposits[0];
       System.out.println(" Depositing: $" + deposit);
       makeDeposit(yourAccount, deposit);
      
       // Now make a withdrawal
       withdrawal = withdrawals[0];
       System.out.println(" Withdrawing: $" + withdrawal);
       makeWithdrawal(yourAccount, withdrawal);
      
       // Now make a withdrawal of the exact remaining balance
       // Note: The fee + withdrawal will exceed the remaining balance!
       withdrawal = withdrawals[5];
       System.out.println(" Withdrawing: $" + withdrawal);
       makeWithdrawal(yourAccount, withdrawal);
      
      
       // Example #4: Transfer between accounts
       System.out.println(" Example #4: Transfers between two accounts");
       System.out.println( " myAccount: " + myAccount +
                       " yourAccount: " + yourAccount);
       // Make a valid transfer from "myAccount" to "yourAccount"
       transfer = transfers[0];
       System.out.println(" Transfering $" + transfer + " from " + myAccount.name() +
               "'s account to " + yourAccount.name() + "'s account");
       transfer(myAccount, yourAccount, transfer);
      
       // Make an invalid transfer (negative amount) from "myAccount" to "yourAccount"
       transfer = transfers[1];
       System.out.println(" Transfering $" + transfer + " from " + myAccount.name() +
               "'s account to " + yourAccount.name() + "'s account");
       transfer(myAccount, yourAccount, transfer);
      
       // Make a valid transfer from "yourAccount" to "myAccount"
       transfer = transfers[2];
       System.out.println(" Transfering $" + transfer + " from " + yourAccount.name() +
               "'s account to " + myAccount.name() + "'s account");
       transfer(yourAccount, myAccount, transfer);
      
       // Make a second valid transfer from "yourAccount" to "myAccount" that results
       // in a balance of $0.01 in "myAccount"
       transfer = transfers[3];
       System.out.println(" Transfering $" + transfer + " from " + myAccount.name() +
               "'s account to " + yourAccount.name() + "'s account");
       transfer(myAccount, yourAccount, transfer);
      
       // Make an invalid transfer (insufficient funds) from "myAccount" to "yourAccount"
       transfer = transfers[4];
       System.out.println(" Transfering $" + transfer + " from " + myAccount.name() +
               "'s account to " + yourAccount.name() + "'s account");
       transfer(myAccount, yourAccount, transfer);
      
       // Make an invalid transfer (insufficient funds) from "yourAccount" to "myAccount"
       transfer = transfers[5];
       System.out.println(" Transfering $" + transfer + " from " + yourAccount.name() +
               "'s account to " + myAccount.name() + "'s account");
       transfer(yourAccount, myAccount, transfer);
      
   } // End static method: main(String[])


   /**************************************************************************
   * Method: introduction()
   *
   * Method Description
   * ------------------
   * This static method describes the Project solution to the User.
   *
   *
   * Pre-Conditions
   * --------------
   * None
   *
   *
   * ------------------------------- Arguments ------------------------------
   * *** No Arguments supplied ***
   *
   *
   * RETurn
   * Type Description
   * ------ ----------------------------------------------------------------
   * void The method RETurns no value
   *
   *
   * Invoked Methods
   * ---------------
   * None
   *
   **************************************************************************
   */
   private static void introduction()
   {
       System.out.println(" Project #8 Solution" +
                       " Chapter 8, Exercise #11, page 568 ");
   }


   /**************************************************************************
   * Method: makeDeposit(BankAccount,double)
   *
   * Method Description
   * ------------------
   * This static method deposits the amount specified (argument) into the
   * specified (reference argument) "BankAccount" object. After the deposit,
   * the account is displayed by calling, indirectly, the overloaded
   * "toString()" class method.
   *
   *
   * Pre-Conditions
   * --------------
   * 1. The "account" reference is not "null"
   *
   *
   * RETurn
   * Type
   * ------
   * None
   *
   * ------------------------------- Arguments ------------------------------
   * Type Name Description
   * ------------ -------- ------------------------------------------------
   * BankAccount account Reference to a "BankAccount" object
   * double deposit Amount of the deposit
   *
   *
   * RETurn
   * Type Description
   * ------ ----------------------------------------------------------------
   * void The method RETurns no value
   *
   *
   * Invoked Methods
   * ---------------
   * None
   *
   **************************************************************************
   */
   private static void makeDeposit(BankAccount account, double deposit)
   {
       // First, attempt to make the deposit
if (account.deposit(deposit) )
{   // A deposit amount >0 was specified, continue...
   // Now "display" the object to the User. By specifying the REFERENCE
   // to the object as an argument in the "println" method, the compiler
   // will generate a call to the overloaded class method, "toString()".
   System.out.println(" " + account);
}
else
{   // Otherwise, an invalid deposit amount was specified
   System.out.println(" Unable to deposit $" +
       String.format("%.2f", deposit));
}
   }


   /**************************************************************************
   * Method: makeWithdrawal(BankAccount,double)
   *
   * Method Description
   * ------------------
   * This static method deposits the amount specified (argument) into the
   * specified (reference argument) "BankAccount" object. After the deposit,
   * the account is displayed by calling, indirectly, the overloaded
   * "toString()" class method.
   *
   *
   * Pre-Conditions
   * --------------
   * 1. The "account" reference is not "null"
   *
   *
   * ------------------------------- Arguments ------------------------------
   * Type Name Description
   * ------------ ---------- ----------------------------------------------
   * BankAccount account Reference to a "BankAccount" object
   * double withdrawal Amount of the withdrawal
   *
   *
   * RETurn
   * Type Description
   * ------ ----------------------------------------------------------------
   * void The method RETurns no value
   *
   *
   * Invoked Methods
   * ---------------
   * None
   *
   **************************************************************************
   */
   private static void makeWithdrawal(BankAccount account, double withdrawal)
   {
       // Attempt to make the withdrawal. The class method, "withdrawal" will
       // RETurn a "boolean" value; "true": Withdrawal made,
       // "false": Withdrawal (+ fee, if applicable) will exceed current
       // balance.
       boolean status = account.withdraw(withdrawal);
    
       if (status)
       {   // Withdrawal was successful, display the remaining balance.
   System.out.println(" " + account);
       }
else
{   // Otherwise, inform the User that withdrawal was NOT made.
   System.out.println(" Unable to withdraw $" +
       String.format("%.2f", withdrawal));
}
    
       // Note: A "return" statement is unnecessary for a method that "returns"
       // "void", but is allowed for completeness.
       return;
   }


   /**************************************************************************
   * Method: transfer(BankAccount,BankAccount,double)
   *
   * Method Description
   * ------------------
   * This static method attempts to withdraw the secified amount from the
   * "source", "BankAccount" object, and if possible, deposits that amount
   * or part thereof, to the "destination", "BankAccount" object.
   * The trasfer is accomplished by invoking the "source" object's non-
   * static data member, "transfer", which RETurns a "bool" value, "true",
   * the transfer occurred.
   *
   *
   * Pre-Conditions
   * --------------
   * 1. The "account" reference is not "null"
   *
   *
   * ------------------------------- Arguments ------------------------------
   * Type Name Description
   * ------------ ------------ --------------------------------------------
   * BankAccount source Reference to the source "BankAccount" object
   * BankAccount destination Reference to the destination object
   * double withdrawal Amount of the withdrawal
   *
   *
   * RETurn
   * Type Description
   * ------ ----------------------------------------------------------------
   * void The method RETurns no value
   *
   *
   * Invoked Methods
   * ---------------
   * None
   *
   **************************************************************************
   */
   private static void transfer(BankAccount source, BankAccount destination,
                               double transferAmount)
   {
       // Attempt to make the transfer. The class method, "transfer" will
       // RETurn a "boolean" value; "true": Transfer was made,
       // "false": Transfer + fee will exceed current balance of the
       // source account.
       double amountTransferred = source.transfer(destination, transferAmount);
    
       if (amountTransferred > 0.0)
       {   // Transfer was successful, display the two accounts.
   System.out.printf(" Source Account: %s" +
                   " Amount Transferred: %.2f" +
                         " Destination Account: %s ",
                         source, amountTransferred, destination);
       }
else
{   // Otherwise, inform the User that withdrawal was NOT made.
   System.out.println(" Unable to transfer $" +
       String.format("%.2f", transferAmount));
}
   }

} // End class definition: Project9_BankAccount