chapter 7.2 while – conditional loops. what is the best description of how many times a while loop...

Download Chapter 7.2 While – Conditional Loops. What is the BEST description of how many times a while loop executes? A.Some fixed number of times that the programmer

If you can't read please download the document

Upload: landyn-oconnor

Post on 13-Dec-2015

220 views

Category:

Documents


1 download

TRANSCRIPT

  • Slide 1

Chapter 7.2 While Conditional Loops Slide 2 What is the BEST description of how many times a while loop executes? A.Some fixed number of times that the programmer can determine before the code runs B.Some fixed number of times that can be calculated with a function C.Some variable number of times that is determined by the distance of one object to another D.Some variable number of times that programmer cannot determine before the code runs Slide 3 What loop header would keep a shark swimming after a goldfish until he was within 0.5 meters behind the goldfish? Slide 4 We change the while loop Boolean expression controlling the chase to this What does it do (when will the loop iterate)? A.Chase until the goldfish turns blue B.Chase until the goldfish turns a color other than blue C.Chase until the shark gets close Slide 5 Section 7.2 While (Indeterminate) Loops While loops execute some number of times that we cannot determine before the code runs Slide 6 If I have a chase that should keep going on until the goldfish turns blue (pretend he turns blue after fleeing for a certain amount of time) what condition should we use to control the while loop in the chase method? D) A and C E) B and C Slide 7 Hint to getting while loops right Humans naturally think until Ill keep spending until I run out of money (balance0) Ill keep dancing while I am not asleep While I have a dirty dish, Ill keep washing dishes Slide 8 Lets have a race A Wind up penguin (he just goes) While loop with walk and spin inside it Jet-pack penguin2 (controlled by