You've asked about two different things, both important to the topic, boolean logic and loop concepts, and from what you've posted you seem to understand the looping part. Let's review that first:
Each of the three loops has a condition, and (as you stated) for
as long as (or while
) the condition is true, the body of the loop will be executed. You seem to have that concept clear. When to use each:
for: when the number of times the body of the loop is to be run is known or can be calculated
while: when the number of times the body of the loop is to be run is uncertain or decided by the user
do/while: when the body of the loop must be run at least once but after that the number of times it is to be run is uncertain or decided by the user
Even though the above are generally true, they are guidelines rather than absolute rules, because any loop can be used in place of any of the others at any time.
As for boolean logic, greater confidence will come with experience, but even the most experienced and confident can write a boolean equation that is confusing. So rule number 1 is to keep the loop condition as simple as possible. Try to keep the number of conditions to 2 or less OR the number of boolean operators to one no matter how many conditions there are. Using the keep it simple approach, in order for the loop body to be executed when the loop conditions are combined with:
of the conditions must be true, or combined with
of the conditions must be true
Yes, reviewing the material in your textbook may help. You might also look for online articles that discuss topics you're having trouble with, because sometimes seeing the topic explained differently may help you see the light.
Hope this helps. Good luck!