Would looping through the arraylist asking the for the withdraw and deposit amounts work? How would I go about that? Put a loop inside the loop for creating the accounts in the arraylist? Or create a seperate loop that calls the objects from the arraylist?

List the steps in order that the program needs to do to find out what the user wants to do.
When the program knows what kind of transaction it is to do what should it do next?
Don't try to write the program until the steps the program is to do has been set.

Should the program get all of the account information before trying to do transactions with any of the accounts?

The assignment is a little unclear. I thought about adding in the option to choose whether to make a withdraw or deposit but the assignment states to ask the user for a withdraw and deposit amount for each account. So, I'm gonna have it ask for both. The next step would then be to withdraw and deposit the correct amounts from each program.

Yes the program should get all of the account information before trying to do the transactions so then I should have a seperate loop for the transactions?

What is the program supposed to do after all the account data is loaded?
Yes, you will be using loops, but you need to describe what the program is going to do in the loop before trying to write any code.

Strange that the assignment would say to ask for both a withdrawal and deposit at the same time.
You could subtract the amounts and only do a single transaction for the difference.

The end result should be that I write a third loop that displays the contents of each of the BankAccounts using the toString method.

In the loop I am trying to write now(the one that asks the user for the withdraw and deposit amounts) it should get the withdraw and deposit amounts from the user and apply it to each bank account. So far I have:

for (int i = 0; i < n; i++) {

            double amount = 0;

            System.out.print("Enter the withdraw amount:");
            amount = in.nextDouble();

            System.out.print("Enter the deposit amount:");
            double deposit = in.nextDouble();  

This asks the user for each amount and accepts the amount. I'm just not sure what code to put in so that it actually goes to the arraylist and deposits or withdraws from the accounts.

My thought is to add...

bankAccounts.withdraw(amount);

into the code but then I get the message:
The method withdraw(double) is undefined for the type ArrayList<BankAccount>
so that clearly is not correct but I don't know what else to do.

You still are trying to write code BEFORE designing the code.
Can you make a list of the steps the program must do? When you get a good design, then try writing the code.

The steps are:
1. Prompt user to enter withdraw and deposit amounts for each bank account
2. Receive information from user
3. Send amounts to the deposit and withdraw methods
4. Perform actions on amounts entered by user
5. Store new balance in arraylist

The step I am stuck on is to send the amounts to the methods but I don't know how to do it.

For step 1, will there be both and the same withdrawl AND a deposit amount to ALL the accounts?
That's a very unusual program requirement. Same amounts to all accounts?
Why add a deposit and subtract a withdrawal at the same time? Why not do just one?

What does step 4 mean? Wasn't that done in step 3

What is done in step 5? The balances are inside of the BankAccount objects, not in the array list.
The BankAccount objects are in the arraylist. Once you add a BankAccount object to the arraylist, you wouldn't be taking it out, unless possibily there was a close account option.
You should call a method in the BankAccount class to update the contents of the object. You won't be adding new balances to the arraylist.

There will be a different withdraw and deposit amount for each account. That is why it's in a loop so it will loop through for each account created. Yeah that is done in step 3 I just wrote out what the computer will be doing. I wasn't sure how that would work for step 5. It makes since that everything is in the arraylist and stays there but I don't know how to access the information to update it based on the withdraw or deposit.

different withdraw and deposit amount for each account

How does the program know which account to update?

how to access the information

The ArrayList class has methods to get access to its contents. You can get a reference to a BankAccount object and call its methods.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.