Tina Comston Comp-111 Week 8 Franklin University |
||||
Week 8 | ||||
Preparation
|
||||
Guided
Learning Activity |
||||
Assignment
Loops There are 3 loop types that are supported in Java. while (condition) { statements to execute } This is a condition controlled pre-test loop. The condition is first checked and if true, the loop executes. It continues to execute as long as the condition is true. This type of loop can always be used, but is most often used when you are unsure of how many times the loop will execute. do { statements to execute } while(condition) This is a condition controlled post-test loop. The do/while loop executes the statements first and then checks the condition. This type of loop is used when you need the statements to execute at least once before checking the condition. for (int varName=default; condition; increment/decrement) { statements to execute } This is a count controlled pre-test loop. This type of loop first checks the condition and if true executes the statements a set number of times. It is used when you know how many times the loop should execute. Regardless of the type of loop the following occurs: set the initial value for the condition check the condition execute the body of the loop modify the condition In the FOR loop these are all combined into the initial statement for (int varName=default; condition; increment/decrement)
YouTube video on loops https://www.youtube.com/watch?v=0ll7vm1GQYE
|
||||
Reflection
Paper
|
||||
Lab 3
|