RU beehive logo ITEC dept promo banner
ITEC 120
2012fall
dbraffitt
ibarland

homeinfolectslabsexamshws
tutor/PIsbreeze (snow day)
Object120 + its docsjava.lang docsjava.util docs

lect09b
loops that accumulate info

We ended last time with:

  int i = 0;  // Index variable: number of times through the loop
  while (i < 1000000) {
    System.out.println( "i is now " + i );
    i = i+1;
  }

Task (for you to do by hand): What is the result of 0+1+2+3+4+…+9?
When you did this by hand, what information did you keep track of?

Let's write the process in pseudo-code: English instructions for your (perhaps rather dense) roommate to follow. Note that your roommate might get interrupted and stop to text a friend; they'll remember which instruction they're working on but won't remember anything else. Have them keep local variables to store any info they need to remember!

homeinfolectslabsexamshws
tutor/PIsbreeze (snow day)
Object120 + its docsjava.lang docsjava.util docs


©2012, Ian Barland, Radford University
Last modified 2012.Oct.24 (Wed)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Powered by PLT Scheme