Public class BankAccountprivate String name private double b
Public class BankAccount{private String name; private double balance; public BankAccount (double b, String s){balance =b; name = n;} public deposit (double d){balance d;} public deposit (double d) {balance += d;} public withdraw (double w) {balance -= w;} public String getName() {return name;} public string getBalance() {return balance; public string toString(){return \'name: + name + \"balance: \" + balance;}} Create one BankAccount object called acotl with the name \"Savings\" and a balance of $525. Create an array to hold 5 BankAccount objects called myAcets Store the account object created in question as the first element in the arraymyAccta. Instantiate the object at index 3 with the values $1000 and name \"vacation\". Deposit $75 to the account with index 2. Assume index 2 is not null. Withdraw $100 from the account with index 4. Assume index 4 is not null. Write a loop to print out all of the accounts in the array myAccts.
Solution
1) BankAccount acc1=new BankAccount();
acc1.Savings=525;
2) int [] myAccts=new int [5];
3) myAccts[1]=acct1.Savings;
4) int [3] myAccts=vacation.BankAccount(1000;);
5) myAccts[2]+=75;
6) myAccts[4]-=100;
7) for(int i=0; i<myAccts.size; i++)
{
System.out.println(myAccts[i]);
}
