1. Nesting Loops and Ifs

This chapter shows how counting loops and if statements are used together to implement the logic of a program.

These examples give you practice in building programs out of fundamental pieces.

Chapter Topics:

      • Adding up even and odd integers
      • Computing N factorial
      • Dropping a brick
      • Making a rectangle of stars

Question 1:

With only paper and pencil, would you like to add up all the integers from one to one thousand?


Source: Bradley Kjell, http://programmedlessons.org/Java9/chap21/ch21_01.html
Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 License.