Answer:
Here is the Bank Account class:
public class Bank Account { //class definition
private String name; //private String type field to hold name
private double balance; // private double type field to hold balance
public Bank Account(String name, double balance) { // parameter constructor that takes
//this keyword is used to refer to the data members name and balance and to avoid confusion between name, balance private member fields and constructor arguments name, balance
this.name = name;
this.balance = balance; }
public void deposit(double amount) { //method to deposit amount
balance = balance + amount; } // adds the amount to the account causing the current balance to increase
public void withdraw(double amount) { //method to withdraw amount
balance = balance - amount; } //subtracts the amount causing the current balance to decrease
public String toString() { // to display the name and current balance
return name + " , $" + balance; } } //returns the name and the current balance separated by a comma and dollar
Explanation:
The explanation is provided in the attached document due to some errors in uploading the answer.