{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

16-07mar15loops

16-07mar15loops - C S 100J 15 M arch 2006 T h e w h ile lo...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 1 CS100J 15 March, 2006 The while loop and assertions Read chapter 7 on loops. The lectures on the ProgramLive CD can be a big help. Some anagrams A decimal point I'm a dot in place Animosity Is no amity Debit card Bad credit Desperation A rope ends it Dormitory Dirty room Funeral Real fun Schoolmaster The classroom Slot machines Cash lost in 'em Statue of liberty Built to stay free Snooze alarms Alas! No more Z's The Morse code Here come dots Vacation times I’m not as active Western Union No wire unsent George Bush He bugs Gore Parishioners I hire parsons The earthquakes That queen shake Circumstantial evidence Can ruin a selected victim Victoria, England’s queen Governs a nice quiet land Eleven plus two Twelve plus one (and they have 13 letters!) 2 The while loop: syntax while ( < condition > ) < repetend > while (< condition > { sequence of declarations and statements } < condition >: a boolean expression. < repetend >: a statement. BUT: We almost always make the < repetend > a block. condition repetend false true 3 The while loop System.out.println(5*5); System.out.println(6*6); System.out.println(7*7); System.out.println(8*8); int k= 5; while ( k <= 8) { System.out.println(k*k); k= k+1; } To execute the while loop: (1) Evaluate condition k <= 8; if false, stop execution.
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}