Gregory M. Kapfhammer
Details in the Textbook
An alternative to using if statements
Cannot encode complex boolean expressions
Sometimes simpler for a programmer to understand
Which approach do you prefer? Why did you pick it?
See Section 6.1 for more details!
Please see page 274 for an example!
Work with a partner to compare while and do-while loops
What is the key difference?
How do pick between these options?
Can you draw a picture to visualize their execution?
Visualize these loops with a diagram
When is it best to use a while loop?
What if we know the number of iterations?
We should try to use the for loop!
What is the structure of a for loop?
Visualize the for loop with a diagram
git pull command!
Build the ComputeMultiples.java program
Run this program like it was on page 282
Try five different inputs for this program
Record one output of this program
How does this program use for loops?
Document each part of the code
This program uses iteration constructs
We will investigate this program during a practical
Do you understand how to this program works?
Could you extend this program with new loops?
Three basic loop statements are functionally equivalent
What if we want to run the loop body at least one time?
What if we know the number of times iteration will occur?
What if we want to use an
Make sure that you understand the trade-offs!
Create a program called
The program should accept two command-line arguments
The first input should be the number of printed symbols
The second input should be the printed symbols
Print the specified number of symbols in the terminal
Can you create, compile, and run this program?
What output does it produce?