### Lab

Remember to review questions starting on p. 342.

### Chapter 5 Loops: Vocabulary

 increment/decrement operators postfix/prefix modes while-loop (a pretest loop) for-loop (a pretest loop) unwinding and hand tracing do-while-loop (a posttest loop) nested loop break statement Control variable, initialization, condition, update; loop body sentinel value counter, running total running totals, accumulator infinite loop Monte Carlo Method

### In Class Practice Activities

• Use a loop to print out the lyrics for 99 Bottles of Beer on the Wall.
• How does one represent a card?
• What is the UML Diagram for the BlackJack Game?
• Do all of these!! Basic Looping Problems (pdf)
• Once we get to nested loops, do all of these!! Nested Loop Problems (pdf)
• By the end of the chapter, you should be able to do all of these practice problems without blinking an eye! They are the kind of coding questions you might see on an exam.
• BlackJack Preliminaries:
• Write a loop that prompts a user for a yes or no. If they don't answer correctly, then keep prompting them until they do.
• Write code to randomly pick a card (index 0-51) and calculate & print the suit (index 0-4) and face (index 0 to 12).
• Write a loop that draws 10 random playing cards, each time printing the name of the card. Note, to print the name, one can use unicode
``````     if (suit == 0) {  // spades
name = "\u2660";
} else if ...
``````
Look up online the unicode for the other suits.
• Add code to compute the value of the card (2-10 for face cards, 10 for JKQ, 1 or 11 for Ace)