16-07mar15loops - 1 1 CS100J 15 March, 2006 The while loop...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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 Im 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, Englands 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....
View Full Document

This note was uploaded on 03/03/2012 for the course CS 100J taught by Professor Davidgries during the Spring '07 term at Cornell University (Engineering School).

Page1 / 2

16-07mar15loops - 1 1 CS100J 15 March, 2006 The while loop...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online